何在GridViewCommandEventArgs中获取当前行

何在GridViewCommandEventArgs中获取当前行

本文介绍了如何在GridViewCommandEventArgs中获取当前行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请提供一个令人沮丧的问题的解决方案:GridViewCommandEventArgs不公开引发事件的行.假设您需要一个itemTemplate来使链接按钮执行删除.您如何获得对正确行的引用?数据网格的DataGridCommandEventArgs通过其Item属性和e.Item.ItemIndex GridViewCommandEventArgs公开行时,只有三个属性:CommandName,CommandArgument和CommandSource(提供对gridview itelf的引用).

我进行了很多搜索,但没有找到任何解决方案.请帮助或提出任何解决方案.

Please provides solutions to a frustrating issue: GridViewCommandEventArgs doesn''t expose the Row that raised the event. Say you need an itemTemplate for a link button to execute deletes.; how do you get a reference to the correct row? While the datagrid''s DataGridCommandEventArgs exposed the row through it''s Item property & e.Item.ItemIndex GridViewCommandEventArgs only three properties: CommandName, CommandArgument & CommandSource (which provides a reference to the gridview itelf).

I searched a lot but not able to get any solution.Please help or suggest any work around.

推荐答案

<asp:GridView ID="gvUser" Width="100%" runat="server" CssClass="Gridview"
AutoGenerateColumns="false" showfooter="true"  DataKeyNames="UserID"
BorderColor="white" HeaderStyle-BackColor="#e0ffff"
HeaderStyle-BorderColor="#b0c4de" FooterStyle-BackColor="white"
onrowcancelingedit="gvUser_RowCancelingEdit" onrowdeleting="gvUser_RowDeleting"
onrowediting="gvUser_RowEditing" onrowupdating="gvUser_RowUpdating" >



在这里,我为删除行创建了一个事件-



Here i have created an event for row deleting-

protected void gvUser_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    string id = gvUser.DataKeys[e.RowIndex].Value.ToString();

    _objUserBAL.fnDeleteDetailByID("tt_Users", "UserId", id);
    BindUserDataConfig();
    BindReportingPerson();
}




使用DatakeyName获取引发事件.

最好的:-)




USe DatakeyName to get the raised event.

All the Best:-)


这篇关于如何在GridViewCommandEventArgs中获取当前行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:40