• 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

  • 相关阅读:
    STL: merge
    STL: rotate
    javascript的prototype继承问题
    日期正则表达式
    有关linq的一系列学习的文章,值得收藏
    EF读取关联数据
    jQuery UI中的日期选择插件Datepicker
    LINQ的基本语法中八个关键字用法说明
    Shell变量内容的删除、替代与替换
    Shell命令别名与历史命令
  • 原文地址:https://www.cnblogs.com/ggbbeyou/p/1857736.html
Copyright © 2020-2023  润新知