如何在行更新事件中访问某些行数据绑定函数

本文关键字:数据绑定 函数 访问 事件 更新 | 更新日期: 2023-09-27 18:32:50

我在行数据绑定事件中有以下代码:

 if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
    {
        string CCC = (string)DataBinder.Eval(e.Row.DataItem, "COLUMN");
        DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("DropDownList1");
    }

如何使代码在行更新事件中工作。我想在行更新事件中添加仅此代码而没有 if 条件。

string CCC = (string)DataBinder.Eval(e.Row.DataItem, "COLUMN");
            DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("DropDownList1");

如何在行更新事件中访问某些行数据绑定函数

这里由我展示示例...对于 SQL 数据适配器更新...这也是我只从这个StackOverFlow中学到的。

private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
{
string MyERowValu = e.Row["sl_no"].ToString().Trim();
if (e.Row["itm_description"].ToString().Trim().Length == 0)
{
//e.Status = UpdateStatus.SkipCurrentRow;
e.Status = UpdateStatus.SkipAllRemainingRows;
}
}

我在Data_Save地区使用的 Bleow 代码...

SQLCon.Open();
blah...blah...blah...blah...
SqlTransaction Trans1 = MyItmDatas.WMSCon.BeginTransaction();
MyDataAdapter1.UpdateCommand.Transaction = Trans1;
MyDataAdapter1.InsertCommand.Transaction = Trans1;
MyDataAdapter1.RowUpdating += new SqlRowUpdatingEventHandler(OnRowUpdating);
MyDataAdapter1.RowUpdating += new SqlRowUpdatingEventHandler(OnRowUpdating);
myDataGrid1.CurrentCell = myDataGrid1.FirstDisplayedCell;
myDataGrid1.EndEdit();
try
{
MyDataAdapter1.Update(ItemTable);
Trans1.Commit();
MessageBox.Show(" ITEMS UPDATED TO ....... ITEM MASTER ", " ITEM MASTER UPDATE ");
}
catch (Exception ex)
{
if (Trans1 != null)
{
Trans1.Rollback();
}
MessageBox.Show(ex.Message, "Item Master Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
SQLCon.Close();
MyDataAdapter1.RowUpdating -= new SqlRowUpdatingEventHandler(OnRowUpdating);
myDataGrid1.Refresh();