问题描述
我有一个链接按钮Repeater控件里面,我想传递给另一页
<&ItemTemplate中GT;
&所述; TR>
< TD BGCOLOR =#D8E1EA的风格=显示:无>
< ASP:标签ID =EMPID=服务器文本='<%#的eval(EMP_ID)%>' />
< / TD>
&所述; TD>
< ASP:LinkButton的ID =lnkRowSelection=服务器文本='<%#的eval(FullEmpName)%>'的CausesValidation =假
的CssClass =navigationlink的CommandName ='<%#的eval(FullEmpName)%>' CommandArgument ='<%#的eval(EMP_ID)%>'
的OnClick =ButtonLink_Click前景色=黑字体下划线=FALSE/>
< / TD>
&所述; TD>
< ASP:标签ID =Label1的=服务器文本='<%#的eval(days_worked)%>' />
< / TD>
&所述; TD>
< ASP:标签ID =Label2的=服务器文本='<%#的eval(total_absents)%>' />
< / TD>
&所述; TD>
< ASP:标签ID =Label5=服务器文本='<%#的eval(days_marked)%>' />
< / TD>
< / TR>
< / ItemTemplate中>
现在我想多值传递给其他页( ManualAttendance.aspx
)与链接按钮
我曾经试过,但有了这个,我只能传递一个值 lnkRowSelection
。文本请告诉我如何可以传递多个列的值?
这就是我试图
保护无效ButtonLink_Click(对象发件人,发送System.EventArgs)
{
// LinkButton的_lnkBtn = rptTeamAverage.Items [I] .FindControl(lnkRowSelection)作为LinkButton的;
LinkButton的lnkRowSelection =(LinkButton的)寄件人;
//标签EMPID =(标签)寄件人; lnkRowSelection.PostBackUrl =?ManualAttendance.aspx ID =+ lnkRowSelection.Text +&放大器; M =+的Request.QueryString [M] +&放大器; S =+ int.Parse(的Request.QueryString [S ]的ToString())+&放大器; SYS =+((System.Collections.Generic.Dictionary<字符串,字符串>)会话[用户])[令牌];
}
您可以在 lnkRowSelection 的
CommandArgument
属性使用分号分隔值code>。比方说,你想传递 EMP_ID
, days_worked
, total_absents $ C $的值C>和
days_marked
,这里就是你需要在ASPX code添加的内容:
< ASP:LinkButton的ID =LinkButton1
=服务器
文字='<%#的eval(FullEmpName)%>'
的CausesValidation =假
的CssClass =navigationlink
的CommandName ='<%#的eval(FullEmpName)%>'
CommandArgument ='&下;%#评估和演示(EMP_ID)+; +评估和演示(days_worked)+; +评估和演示(total_absents)+; +的eval(days_marked)%>'
的OnClick =ButtonLink_Click
前景色=黑
字体下划线=FALSE/>
然后 ButtonLink_Click
:
保护无效ButtonLink_Click(对象发件人,发送System.EventArgs)
{
LinkButton的lnkRowSelection =(LinkButton的)寄件人;
字符串[]参数= lnkRowSelection.CommandArgument.Split(';');
字符串EMP_ID =参数[0];
串days_worked =参数[1];
字符串total_absents =参数[2];
串days_marked =参数[3]; //通EMP_ID,days_worked,total_absents,并通过查询字符串days_marked到另一个页面
Response.Redirect(string.Format(\"ManualAttendance.aspx?id={0}&daysworked={1}&totalabsents={2}&daysmarked={3}\", EMP_ID,days_worked,total_absents,days_marked),FALSE);
}
I have a Link Button Inside Repeater Control and I want pass to another page
<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>
now I want to pass multiple values to Other Page (ManualAttendance.aspx
) with Link ButtonI have tried this but with this i can only pass one value lnkRowSelection
.Text Please tell me how can i pass multiple column values??this is what i have tried
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"];
}
You can use semicolon separated values in the CommandArgument
property of lnkRowSelection
. Let's say you want to pass values of emp_id
, days_worked
, total_absents
, and days_marked
, here's what you need to add in the aspx code:
<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" />
then in ButtonLink_Click
:
protected void ButtonLink_Click(object sender, System.EventArgs e)
{
LinkButton lnkRowSelection = (LinkButton)sender;
string[] arguments = lnkRowSelection.CommandArgument.Split(';');
string emp_id = arguments[0];
string days_worked = arguments[1];
string total_absents = arguments[2];
string days_marked = arguments[3];
// pass emp_id, days_worked, total_absents, and days_marked to another page via query string
Response.Redirect(string.Format("ManualAttendance.aspx?id={0}&daysworked={1}&totalabsents={2}&daysmarked={3}", emp_id, days_worked, total_absents, days_marked), false);
}
这篇关于如何通过使用链接按钮多个值内转发到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!