如何添加为变量赋值的e.row.attribut [英] how to add e.row.attribut that assign value to a variable

查看:97
本文介绍了如何添加为变量赋值的e.row.attribut的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图删除超链接上的gridview行点击



这是我的超链接



Im trying to delete a gridview row on hyperlink click

this is my hyper link

<a href='<%=ResolveUrl("~/Producter/Delete?id=" + id) %>' ID="A2">Delete</a>



id是我想要赋值的变量,这是我的GridView1_RowDataBound




id is a variable that i want to assign value to, this is my GridView1_RowDataBound

 int id ;

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
      // somthing like
      // selected row have this id => DataBinder.Eval(e.Row.DataItem, "Id").ToString();
      // e.Row.Attributes.Add("Onclick", id = this clicked row's id); 
    }
}

推荐答案

<asp:TemplateField HeaderText="Case Number">
<ItemTemplate>
<asp:Label ID="lblCaseID" runat="server" Text='<%#Eval("CID")%>' Visible="false"></asp:Label>
<asp:LinkButton ID="lblCNumber" Width="100px" runat="server" Text='<%#Eval("CName")%>'

CommandArgument='<%#bind("CID") %>' CommandName="delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>


这篇关于如何添加为变量赋值的e.row.attribut的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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