asp.net中网格视图中的链接按钮 [英] link buttons in grid view in asp.net

查看:90
本文介绍了asp.net中网格视图中的链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用asp.net中的链接按钮通过其rowcommand属性处理事件,但它始终在其e.CommandArgument
中显示"(空)值
这是我的代码:

I m using link button in asp.net for handling their event i m using its rowcommand property but it always shows "" (null) value in its e.CommandArgument

this is my code:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

            DataSourceID="SqlDataSource1" DataKeyNames = "id" OnRowCommand = "GridView1_RowCommand">
            <columns>
                 <asp:TemplateField>
                    <itemtemplate>
                        <asp:LinkButton ID="LinkButton1" CommandName = "getid" runat="server" 

                            Text='<%# Eval("id") %>' CommandArgument='<%# Eval("id") %>'>
                    </itemtemplate>
                
            </columns>


protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        TextBox1.Text = e.CommandName.ToString();
    }


字段eval("id")不为空.它包含整数值(1,2,3,4,...)

告诉我是否做错了什么


the field eval("id") is not empty. it contains integer values (1,2,3,4,...)

tell me if i m doing something wrong

推荐答案

像这样在行命令中替换

if(e.CommandName =="getid")
TextBox1.Text = e.CommandName.ToString();
replace in row command like this

if(e.CommandName=="getid")
TextBox1.Text = e.CommandName.ToString();


您的page_load是否包含
Does your page_load contains
if(!IsPostBack)


用户使用以下链接.

http://csharpdotnetfreak.blogspot.com/2009/04/linkbutton-gridview-querystring.html [^ ]

希望这能解决您的问题.

谢谢
拉胡尔(Rahul)
User the below link.

http://csharpdotnetfreak.blogspot.com/2009/04/linkbutton-gridview-querystring.html[^]

Hope this will resolve your problem.

Thanks
Rahul


这篇关于asp.net中网格视图中的链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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