GridView模板的LinkButton传递多个参数

通过GridView模板的LinkButton的CommandArgument传递参数,传递一个参数是常用的,但是也可以传递多个参数

.aspx中的代码为:

view plaincopy to clipboardprint?
01.<asp:TemplateField HeaderText="课程编号" SortExpression="课程编号">  
02.                            <ItemTemplate>  
03.                                <asp:LinkButton ID="LinkButtonCourseNO" runat="server"   
04.                                    Text='<%# Bind("课程编号") %>' CommandName="ButtonClick"   
05.                                    CommandArgument='<%# Eval("ID")+","+Eval("课程名称")+","+Eval("Approved")%>'></asp:LinkButton>  
06.                            </ItemTemplate>  
07.                        </asp:TemplateField> 
<asp:TemplateField HeaderText="课程编号" SortExpression="课程编号">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButtonCourseNO" runat="server"
                                    Text='<%# Bind("课程编号") %>' CommandName="ButtonClick"
                                    CommandArgument='<%# Eval("ID")+","+Eval("课程名称")+","+Eval("Approved")%>'></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>

.cs代码为:

 
view plaincopy to clipboardprint?
01.protected void GViewOutlineList_RowCommand(object sender, GridViewCommandEventArgs e)  
02.{  
03.    if(e.CommandName == "ButtonClick")  
04.    {  
05.        //Response.Write(e.CommandArgument.ToString());  
06.        object [] arguments = e.CommandArgument.ToString().Split(',');  
07.        //Response.Write(arguments.Length.ToString());  
08.        //int OutlineID = Convert.ToInt32(e.CommandArgument);  
09.        Response.Redirect("a.aspx?OutlineID="+Convert.ToInt32(arguments[0])+"&CourseName="+arguments[1].ToString()+"&StateApproved="+Convert.ToInt32(arguments[2]));  
10.    }  
11.} 

 

本文来自CSDN博客,出处:http://blog.csdn.net/kdmhh/archive/2009/08/26/4485762.aspx

转载于:https://www.cnblogs.com/ggbbeyou/archive/2010/10/21/1857736.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值