This is driving me nuts.
I have the following code that, when a button is clicked, a gridview will be populated with data based on the number a client enters into a text box (tbxHowMany).
protected void btnDisplayTopReport_Click(object sender, EventArgs e)
{
if (radPa.Checked)
{
CompleteWeightsDataContext db = new CompleteWeightsDataContext
int max = 0;
if (int.TryParse(tbxHowMany.Text, out max))
{
var queryPa = db.tblOnlineReportingCOMPLETEWeights
.Where (x => x.MaterialLevel == "Primary" && x.MaterialText == "Paper")
.OrderByDescending (x => x.ProductPercentage).Take(max);
GridView1.DataSourceID = "queryPa";
GridView1.DataBind();
}
}
else if (radGl.Checked)
{
CompleteWeightsDataContext db = new CompleteWeightsDataContext
int max = 0;
if (int.TryParse(tbxHowMany.Text, out max))
{
var queryGl = db.tblOnlineReportingCOMPLETEWeights
.Where (x => x.MaterialLevel == "Primary" && x.MaterialText == "Glass")
.OrderByDescending (x => x.ProductPercentage).Take(max);
GridView1.DataSourceID = "queryGl";
GridView1.DataBind();
}
}
}
Unfortunately I keep on getting "a new expression requires (),[], etc" on the first int.
Can someone explain to me the error and/or what I have done wrong and how I can work around this?
Apologies for the, most likely dim, question.