2 my 00 my_00 于 2015.06.14 11:09 提问

求助!!:Asp.net如何传递值??
我在ASp.net前台Source里面添加了一个GridView,代码如下:
  <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CssClass="MyLine" DataKeyNames="OrderID" GridLines="None" Height="100%" HorizontalAlign="Center" OnPageIndexChanging="gvOrderList2_PageIndexChanging" OnRowDataBound="GridView2_RowDataBound" PageSize="12" Width="100%">
<Columns>
<asp:BoundField HeaderText="序号" ReadOnly="True">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="courseID" HeaderText="课程ID" ReadOnly="True">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
                </asp:BoundField>
<asp:BoundField DataField="teacherID" HeaderText="教师ID" ReadOnly="True">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
                </asp:BoundField>
<asp:BoundField DataField="teacherName" HeaderText="教师姓名" ReadOnly="True">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
                </asp:BoundField>
<asp:BoundField DataField="studentID" HeaderText="评价学生ID" ReadOnly="True">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
                </asp:BoundField>
<asp:BoundField DataField="studentName" HeaderText="评价学生姓名" ReadOnly="True">
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:TemplateField>
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>
<asp:LinkButton ID="lnkbtnGoPay" runat="server" CommandArgument='<%#Eval("courseID") %>' OnClick="lnkbtnGoPay_OnClick" OnCommand="lnkbtnGoPay_Command">去查看</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

其中Linkbutton的lnkbtnGoPay_Command事件后台代码如下:

 protected void lnkbtnGoPay_Command(object sender, CommandEventArgs e)
    {
        Response.Redirect("EvaluateTeacherDetail.aspx?courseID=" + e.CommandArgument);
    }

问题:我如何在lnkbtnGoPay_Command事件中同时传递courseID和studentID?
形如: Response.Redirect("EvaluateTeacherDetail.aspx?courseID=" + e.CommandArgument+"&studentID="+????????????);这里?处该怎么写呢??

2个回答

caozhy
caozhy   Ds   Rxr 2015.06.14 11:37
 <%#Eval("courseID")+"|"+Eval("studentID") %>

string[] arr = e.CommandArgument.Split('|');
Response.Redirect("EvaluateTeacherDetail.aspx?courseID=" +arr[0] + "&studentID=" + arr[1];
caozhy
caozhy e.CommandArgument.ToString().Split
2 年多之前 回复
my_00
my_00 Split 有红色下划线提示??
2 年多之前 回复
caozhy
caozhy   Ds   Rxr 2015.06.14 11:37

Response.Redirect("EvaluateTeacherDetail.aspx?courseID=" +arr[0] + "&studentID=" + arr[1]);

Csdn user default icon
上传中...
上传图片
插入图片