如何在Onclick事件中获取行索引 [英] How to get the row Index in Onclick event

查看:346
本文介绍了如何在Onclick事件中获取行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在OnClick事件中从gridview获取rowindex ...任何人都可以帮助我....



I couldn't get the rowindex from the gridview in OnClick event... Can anyone help me ....

protected void Abeyance_Click(Object sender, System.EventArgs e)
{
    int memoid = Convert.ToInt32(Session["MemoID"]);
    string description = TextBox3.Text;
    string priority = TextBox4.Text;
    DateTime dt2 = DateTime.ParseExact(TextBox5.Text, "d/M/yyyy", null);
    objMemoBAL.InsertToAbeyance("MemoAbeyance", memoid, description, priority, dt2, "Internal Memo",Session["Empcode"].ToString());
        
    HiddenField hdnMemoId = new HiddenField();
    LinkButton lnk = sender as LinkButton;
    
    GridViewRow gvrCurrent = ((LinkButton)lnk).NamingContainer as GridViewRow;
    hdnMemoId = (HiddenField)gvrCurrent.FindControl("hdnMemoId");
    int id = Convert.ToInt32(gvList.DataKeyNames[gvrCurrent.RowIndex]);
            
    gvList.DeleteRow(id);
            
    Response.Redirect("frmInternalMemo.aspx");
}// Abeyance and Defer

推荐答案

访问这里......



get-gridview-selected-row-on-button.html [ ^ ]
visit here...

get-gridview-selected-row-on-button.html[^]


GridViewRow gvrow = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;


这篇关于如何在Onclick事件中获取行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆