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);
}