Help On Retrieving Id in link button click while directing

Posted by Vijayar under C# on 2/22/2012 | Points: 10 | Views : 1792 | Status : [Member] | Replies : 2
Hi
I am displaying all jobs in repeater and placing a link button to display the full details in pop up in career page.In pop i a m again placing a link button called Apply in career pageand redirecting to another page called Apply and filling the details in that page.I need to catch the id of job for which iam applying.How to do this.It's Very urgent

vijaya


Responses

Posted by: Rajkatie on: 2/22/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi,
you can set commandName property of linkbutton with unqiue id and get thats value in Click event of linkbutton using following way
string id = ((LinkButton) sender).CommandName

Rajesh Patel
R.P.A Developer | Developer Trainer | Clean Code Evangelist

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijayar on: 2/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi
I am getting empty string
<asp:LinkButton ID="lnkapply" runat="server" OnClick="lnkapply_Click" CommandName='<%#Eval("JobId")%>' CssClass="style" >Apply</asp:LinkButton></td></tr>

protected void lnkapply_Click(object sender, EventArgs e)
{


try
{
string id = ((LinkButton)sender).CommandName;
Response.Redirect("frmApplyJob.aspx");

}
catch (Exception ex)
{
logger.Error("General Exception", ex);
}
}

vijaya

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response