Reputation: 23
Can anyone help me with this kind of error?
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1002: ; expected
This seems to cause the error:
Line 69: string code = grdViews.DataKeys[index].Value.ToString();
Line 70:
Line 71: IEnumerable<DataRow> query = from i in dt.AsEnumerable()where i.Field<String>("Code").Equals(code)select i;
Line 72: DataTable detailTable = query.CopyToDataTable<DataRow>();
Line 73: DetailsView1.DataSource = detailTable;
This is the sourcecode:
protected void grdViews_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName.Equals("detail"))
{
int index = Convert.ToInt32(e.CommandArgument);
string code = grdViews.DataKeys[index].Value.ToString();
IEnumerable<DataRow> query = from i in dt.AsEnumerable()where i.Field<String>("Code").Equals(code)select i;
DataTable detailTable = query.CopyToDataTable<DataRow>();
DetailsView1.DataSource = detailTable;
DetailsView1.DataBind();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"<script type='text/javascript'>");
sb.Append("$('#currentdetail').modal('show');");
sb.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"ModalScript", sb.ToString(), false);
}
}
Upvotes: 2
Views: 329
Reputation: 21897
The line
IEnumerable<DataRow> query =
from i in dt.AsEnumerable()where i.Field<String>("Code").Equals(code)select i;
is not valid. You need spaces in between the statements, like so:
IEnumerable<DataRow> query =
from i in dt.AsEnumerable()
where i.Field<String>("Code").Equals(code)
select i;
Upvotes: 1