任何人都可以帮助我。我已经设法让 RowEditing 的功能正常工作,现在正试图让 RowUpdating 继续工作。我的 gridview 设置如下
<asp:GridView ID="CountryGridView" runat="server" AutoGenerateColumns="false" CssClass="mGrid" OnRowEditing="CountryGridView_RowEditing" OnRowCancelingEdit="CountryGridView_RowCancelingEdit" >
<Columns>
<asp:BoundField ReadOnly="true" DataField="i_SK_Accom" HeaderText="i_SK_Accom" Visible="false" />
<asp:BoundField ReadOnly="true" DataField="Accom_Code" HeaderText="Accom Code" />
<asp:BoundField ReadOnly="true" DataField="Accom_Name" HeaderText="Accom Name" />
<asp:BoundField DataField="OP49_Required" HeaderText="OP49 Required?" />
<asp:BoundField DataField="Weekly" HeaderText="Weekly" />
<asp:BoundField DataField="Daily" HeaderText="Daily" />
<asp:CommandField ShowEditButton="true" ButtonType="Image" EditImageUrl="~/Images/Edit.gif" UpdateImageUrl="~/Images/save.png" CancelImageUrl="~/Images/cancel.png" ControlStyle-CssClass="ImageButton" />
</Columns>
</asp:GridView>
我试图让 RowUpdating 传递由于要更新为 MS SQL 上预编译存储过程的参数的列。通常的方法如下,但我正在努力让 gridview 工作。
SqlCommand commEditConsultant = new SqlCommand("IFACE_JFA_ACCOM", conn.sbConn);
commEditConsultant.CommandType = CommandType.StoredProcedure;
try
{
commEditConsultant.Parameters.Add("@Statement", SqlDbType.VarChar).Value = "AccomUpdate";
commEditConsultant.Parameters.Add("@Page", SqlDbType.VarChar).Value = "OP49";
commEditConsultant.Parameters.Add("@PC_Username", SqlDbType.VarChar).Value = HttpContext.Current.User.Identity.Name.ToString();
commEditConsultant.Parameters.Add("@Season_Name", SqlDbType.VarChar).Value = Season.Text;
commEditConsultant.Parameters.Add("@i_SK_Accom", SqlDbType.VarChar).Value = Request["i_SK_Accom"].Trim().ToString();
commEditConsultant.Parameters.Add("@OP49_Required", SqlDbType.VarChar).Value = ddl_OP49Required.SelectedItem.Value;
commEditConsultant.Parameters.Add("@Weekly", SqlDbType.VarChar).Value = ddl_OP49Weekly.SelectedItem.Value;
commEditConsultant.Parameters.Add("@Daily", SqlDbType.VarChar).Value = ddl_OP49Daily.SelectedItem.Value;
}
上面指定的字段与 gridview 所需的字段相同,但我正在努力将 gridviewrRowEditing
值转换为变量/参数以传递给 SQLCommand。
感兴趣的ID:
DataBinder - BindCountryGrid
DataReader - CountryGridSelectReader