如何在DeleteCommand事件上获取radgrid中的列值
大家好 我有一个像这样的radgrid:
<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>
现在我想获取DeleteCommand事件中“materialName”列的值。 我使用这段代码:
GridDataItem da = e.Item as GridDataItem;
string name = da["materialName"].Text;
或这段代码:
name = RadGrid1.MasterTableView.Items[e.Item.ItemIndex]["materialName"].Text;
但返回值是字符串空。 如果有人有想法,请帮助我。 提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先获取 id,然后从该 id 你将获得名称:
First get the id and then from that id u will get name with:
您可以使用 UniqueName 来获取列的值:
da.item["UniqueName"].Text
You can use UniqueName to get the value of the column:
da.item["UniqueName"].Text