[英]Radgrid get cell value when in edit mode
I have a radgrid and a textbox where I would like to show the value of a column when the record is in edit mode. 我有一个radgrid和一个文本框,我想在记录处于编辑模式时显示列的值。 The value I would like to get is contained in a readonly column and it is listed in DataKeyNames, it is basically the transaction id given by the SQL database when the item is created.
我想要得到的值包含在一个readonly列中,它列在DataKeyNames中,它基本上是创建项目时SQL数据库给出的事务ID。
<MasterTableView CommandItemDisplay="TopAndBottom" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="TransazioneID" AllowFilteringByColumn="True">
I cannot get it out. 我无法理解。
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
string str = item["TransazioneID"].Text;
TextBox1.Text = str;
The code doesn't give me errors but shows nothing. 代码没有给我错误但没有显示任何内容。 How can I get the value of "TransactionID" for the record in edit mode?
如何在编辑模式下获取记录的“TransactionID”值?
Try the following code to get the datakey value in edit mode. 请尝试以下代码以在编辑模式下获取datakey值。
protected void rdg_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string str = editedItem.GetDataKeyValue("TransazioneID").ToString();
TextBox1.Text = str ;
}
}
Try this code , 试试这段代码,
GridEditableItem editedItem = e.Item as GridEditableItem;
int tID = Int32.Parse(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["TransazioneID"].ToString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.