2013-08-01 55 views
2

任何人都可以幫助我解決這類錯誤嗎?ASP.NET中的CS1002錯誤頁面

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

回答

1

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; 
+0

另外一個問題,我已經做到了,但還有另一種錯誤那就是:70 線:\t 線71:\t IEnumerable的查詢= 72號線:from i in dt.AsEnumerable() Line 73:where i.Field (「Code」)。Equals(code) Line 74:select i; – Gilbert

+1

錯誤是什麼?使用未分配的局部變量'code'? – terrybozzio