2013-10-22 12 views
-4

我得到錯誤Preprocessor directives must appear as the first non-whitespace character on a line.我需要在代碼中更改以使其工作?預處理器指令必須作爲第一個非空白字符出現在一行上

protected void Button3_Click(object sender, EventArgs e) 
    { 
     DataTable dt = new DataTable(); 
     dt.Columns.AddRange(new DataColumn[21] { new DataColumn("Siebel_SR#"), 
      new DataColumn("Siebel_SR#1"), new DataColumn("Tran_Qty"), new DataColumn("Ord_Sou_Ref"), 
      new DataColumn("Tran_Reference"), new DataColumn("[Ord Number]"), new DataColumn("[Ord Number1]"), 
      new DataColumn("Transaction_Type_Id"), new DataColumn("Trans_Date"), new DataColumn("[Trans Sub]"), 
      new DataColumn("Business"), new DataColumn("New_DFF_SR#"), new DataColumn("Reason_Name"), 
      new DataColumn("Line_Type"), new DataColumn("Org"), new DataColumn("Sub_Inv"), new DataColumn("Part_Num"), 
      new DataColumn("[Last Updated By]"), new DataColumn("[Created By]"), new DataColumn("Employee"), new DataColumn("DateWorked") }); 
     foreach (GridViewRow row in GridView1.Rows) 
     { 
      if (row.RowType == DataControlRowType.DataRow) 
      { 
       CheckBox chk = (row.Cells[0].FindControl("chkSelect") as CheckBox); 
       if (chk.Checked) 
       { 
        string Siebel_SR# = row.Cells[2].Text; 
        string Tran_Qty = row.Cells[3].Text; 
        string Ord_Sou_Ref= row.Cells[4].Text; 
        string Tran_Reference = row.Cells[5].Text; 

        string Transaction_Type_Id = row.Cells[8].Text; 
        string Trans_Date = row.Cells[9].Text; 

        string Business = row.Cells[11].Text; 

        string Reason_Name = row.Cells[13].Text; 
        string Line_Type = row.Cells[14].Text; 
        string Org = row.Cells[15].Text; 
        string Sub_Inv = row.Cells[16].Text; 
        string Part_Num = row.Cells[17].Text; 


        string Employee = row.Cells[20].Text; 
        string DateWorked = row.Cells[21].Text; 

        dt.Rows.Add(Tran_Qty ,Ord_Sou_Ref , Tran_Reference , Transaction_Type_Id, Trans_Date , 
        Business , Reason_Name ,Line_Type , Org , Sub_Inv , Part_Num , Employee , DateWorked ); 
       } 
      } 
     } 
     GridView3.DataSource = dt; 
     GridView3.DataBind(); 
    } 
+2

編輯你的帖子,並把你的問題,如果可能的話,你的錯誤。另外,爲您的編程語言添加標籤。 – Andrew

+1

我不禁想知道,如何在沒有學習如何在SO上提出問題的基礎知識的情況下獲得2K聲望? – hyde

+0

這可能有助於C#預處理器指令:http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx – Sorceri

回答

4

C#預處理指令與#開始,如#if#define#region等。每個必須在其自身的線。即使在一個人面前發表評論也會產生這個錯誤。

例如:

/* some comment*/ #region SOMETHING 

#endregion 

會給這個錯誤,因爲#region不能收到任何東西(除了可能是空白)。

+0

Thanx bro..for help ... –

+0

當然沒問題。只需點擊_accept_按鈕,我們甚至可以調用它;) – jltrem

相關問題