gpt4 book ai didi

c# - ASP.NET 页面中的 CS1002 错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:38:23 27 4
gpt4 key购买 nike

谁能帮我解决这种错误?

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

这似乎导致了错误:

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;

这是源代码:

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);
}
}

最佳答案

线

IEnumerable<DataRow> query = 
from i in dt.AsEnumerable()where i.Field<String>("Code").Equals(code)select i;

无效。语句之间需要空格,如下所示:

IEnumerable<DataRow> query = 
from i in dt.AsEnumerable()
where i.Field<String>("Code").Equals(code)
select i;

关于c# - ASP.NET 页面中的 CS1002 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17983283/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com