myCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.int, 20));

解决方案 »

  1.   

    myCommand.Parameters["@id"].Value = myDataList.DataKeys[(int)E.Item.ItemIndex];
      

  2.   

    剛才那個問題解決了,馬上給分,附加一個問題我現在調試提眎錯誤如下:
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: 
    Line 170: for (int i=0; i<4; i++)
    Line 171: {
    Line 172: String colvalue = ((TextBox)E.Item.FindControl(cols[i])).Text;
    Line 173: myCommand.Parameters["@" + cols[i]].Value = colvalue;
    Line 174: }
     
    Source File: c:\inetpub\wwwroot\oa\main.aspx.cs    Line: 172