C# 如何在sql数据库中一次更新GridView行
我有DLL类来调用这个表C# 如何在sql数据库中一次更新GridView行,c#,asp.net,sql,sql-server,gridview,C#,Asp.net,Sql,Sql Server,Gridview,我有DLL类来调用这个表 public DataTable GetTemTableValue(string TableName) { SqlConnection conn = new SqlConnection(sConnectionString); conn.Open(); string query = "select * from " + TableName + ""; SqlCommand cmd = c
public DataTable GetTemTableValue(string TableName)
{
SqlConnection conn = new SqlConnection(sConnectionString);
conn.Open();
string query = "select * from " + TableName + "";
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = query;
DataTable ds = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
conn.Close();
return ds;
}
我正在将表绑定到网格视图
private void LoadData()
{
clsDataAccess objDAL = new clsDataAccess();
DataTable DS = new DataTable();
string objBLL = DDLTemTableList.SelectedValue.ToString();
DS = objDAL.GetTemTableValue(objBLL);
if (DS != null && DS.Rows.Count != 0)
{
lblNoRecord.Visible = false;
foreach (DataColumn col in DS.Columns)
{
//Declare the bound field and allocate memory for the bound field.
BoundField bfield = new BoundField();
//Initalize the DataField value.
bfield.DataField = col.ColumnName;
//Initialize the HeaderText field value.
bfield.HeaderText = col.ColumnName;
//Add the newly created bound field to the GridView.
GVDataEntry.Columns.Add(bfield);
}
GVDataEntry.DataSource = DS;
GVDataEntry.DataBind();
GVDataEntry.Visible = true;
}
else
{
lblNoRecord.Visible = true;
GVDataEntry.DataSource = null;
GVDataEntry.DataBind();
//GVDataEntry.EmptyDataText = "No recorddata found";
}
所以表正在加载到网格视图。每次我更改dropdownbox中的表并按下搜索按钮时,列都会动态更改,因此如何通过使用行编辑、行更新功能更新网格视图中的数据,并且需要将日期存储在数据库中