how to get a column value in radgrid on DeleteCommand event
Hi All I have a radgrid like this :
<cc1:RadGridCustomized ID="RadGrid1" runat="server" OnNeedDataSource="RadGridCustomized1_NeedDataSource"
OnPreRender="RadGridCustomized1_PreRender" OnUpdateCommand="RadGridCustomized1_UpdateCommand"
OnDeleteCommand="RadGridCustomized1_DeleteCommand" OnInsertCommand="RadGridCustomized1_InsertCommand"
OnItemCreated="RadGridCustomized1_OnItemCreated">
<MasterTableView DataKeyNames="ID">
<Columns>
<telerik:GridTemplateColumn HeaderText="گروه آزمایش" Visible="false">
<ItemTemplate>
<%# Eval("HSEWaterExamGroupName") %>
</ItemTemplate>
开发者_如何转开发 <EditItemTemplate>
<telerik:RadComboBox OnDataBinding="RadGridCustomized1_ccbBinding3" runat="server"
ID="cbbHSEWaterExamsBaseGroup">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="نام ماده/ آزمایش" UniqueName="materialName">
<ItemTemplate>
<%# Eval("HSEWaterExamBaseName") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox OnDataBinding="RadGridCustomized1_ccbBinding4" runat="server"
ID="cbbName">
</telerik:RadComboBox>
<telerik:RadTextBox ID="txtName" Enabled="false" Visible="false" runat="server" >
</telerik:RadTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</cc1:RadGridCustomized>
now i want get the value of column "materialName" in DeleteCommand event. I use this code:
GridDataItem da = e.Item as GridDataItem;
string name = da["materialName"].Text;
or this code:
name = RadGrid1.MasterTableView.Items[e.Item.ItemIndex]["materialName"].Text;
but the return value is string empty. plz help me if any one has idea to do this . thanks in advance.
First get the id and then from that id u will get name with:
int id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"];
You can use UniqueName to get the value of the column:
da.item["UniqueName"].Text
精彩评论