DataRow row=null;
DataTable table=null;
object key=e.Cell.Row.DataKey;
table=dataSet31.Tables[e.Cell.Band.BaseTableName]; //Try to find the row that needs to be updated.
if (key!=null)
row=table.Rows.Find(key);
在调试状态下 发现key有值,但row=table.Rows.Find(key)就取不出来...
需要什么特殊设置么?
DataTable table=null;
object key=e.Cell.Row.DataKey;
table=dataSet31.Tables[e.Cell.Band.BaseTableName]; //Try to find the row that needs to be updated.
if (key!=null)
row=table.Rows.Find(key);
在调试状态下 发现key有值,但row=table.Rows.Find(key)就取不出来...
需要什么特殊设置么?
没给Row.DataKey赋过值啊,默认的to Paradise_heida(学海无涯,回头是岸!)
key为行数 结果是1,2什么的
有主键,但是就是得不到ROW
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!this.IsPostBack)
{
//UltraWebGrid1.DisplayLayout.AllowUpdateDefault=AllowUpdate.Yes;
UltraWebGrid1.DataSource=dataSet31.Tables["stationmanual"].DefaultView;
sqlDataAdapter1.SelectCommand = new SqlCommand("select * from stationmanual", sqlConnection1);
sqlDataAdapter1.Fill(dataSet31);
UltraWebGrid1.DataBind();
}
}private void UltraWebGrid1_UpdateCellBatch(object sender, Infragistics.WebUI.UltraWebGrid.CellEventArgs e)
{
DataRow row;
DataTable table=null;
object key=e.Cell.Row.DataKey;
table=dataSet31.Tables[e.Cell.Band.BaseTableName]; //Try to find the row that needs to be updated.
if (key!=null)
row=table.Rows.Find(key);
//Try to update the cell in this row.
if(row!=null)
{
try
{
object newVal=e.Cell.Value;
row[e.Cell.Column.Key]=newVal;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
dataSet31.RejectChanges();
}
}
}
sqlDataAdapter1.MissingSchemaAction = MissingSchemaAction.AddWithKey;
sqlDataAdapter1.SelectCommand = ...