How to get column value in radgrid on DeleteCommand event

Hello everyone. I have such a rajit:

<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 to get the value of the "materialName" column in the DeleteCommand event. I am using 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 empty. Plz help me if anyone has an idea to do this. thanks in advance.

+3
source share
2 answers

First enter id, and then from this id u get the name with:

int id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"];
+1
source

You can use UniqueName to get the column value:

da.item["UniqueName"].Text

+1
source

All Articles