我在Repeater Control中有一个链接按钮,我希望传递到另一个页面
<ItemTemplate>
<tr>
<td bgcolor="#D8E1EA" style="display: none">
<asp:Label ID="empId" runat="server" Text='<% # Eval("emp_id")%>' />
</td>
<td>
<asp:LinkButton ID="lnkRowSelection" runat="server" Text='<% # Eval("FullEmpName")%>' CausesValidation="false"
CssClass="navigationlink" CommandName='<% # Eval("FullEmpName")%>' CommandArgument='<%#Eval("emp_id") %>'
OnClick="ButtonLink_Click" ForeColor="black" Font-Underline="false" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<% # Eval("days_worked")%>' />
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<% # Eval("total_absents")%>' />
</td>
<td>
<asp:Label ID="Label5" runat="server" Text='<% # Eval("days_marked")%>' />
</td>
</tr>
</ItemTemplate>
现在我想通过链接按钮将多个值传递给其他页面(ManualAttendance.aspx
)
我试过这个但是这个我只能传递一个值lnkRowSelection
。文本请告诉我如何传递多个列值?
这就是我试过的
protected void ButtonLink_Click(object sender, System.EventArgs e)
{
//LinkButton _lnkBtn = rptTeamAverage.Items[i].FindControl("lnkRowSelection") as LinkButton;
LinkButton lnkRowSelection = (LinkButton)sender;
//Label empId = (Label)sender;
lnkRowSelection.PostBackUrl = "ManualAttendance.aspx?id=" + lnkRowSelection.Text + "&M=" + Request.QueryString["M"] + "&S=" + int.Parse(Request.QueryString["S"].ToString()) + "&sys=" + ((System.Collections.Generic.Dictionary<string, string>)Session["User"])["Token"];
}
答案 0 :(得分:3)
您可以在CommandArgument
的{{1}}属性中使用以分号分隔的值。假设您要传递lnkRowSelection
,emp_id
,days_worked
和total_absents
的值,这是您需要在aspx代码中添加的内容:
days_marked
然后在<asp:LinkButton ID="LinkButton1"
runat="server"
Text='<% # Eval("FullEmpName") %>'
CausesValidation="false"
CssClass="navigationlink"
CommandName='<% # Eval("FullEmpName") %>'
CommandArgument='<%#Eval("emp_id") + ";" + Eval("days_worked") + ";" + Eval("total_absents") + ";" + Eval("days_marked") %>'
OnClick="ButtonLink_Click"
ForeColor="black"
Font-Underline="false" />
:
ButtonLink_Click