how to use click event of button in itemtemplate of datalist.
-
Hello every body, I want to use an button in item template of datalist and i want dat on the click event of button the page should to redirected to the given url. But i am unable to do dat . pleae help me Regards Rahul rahul saini
-
Hello every body, I want to use an button in item template of datalist and i want dat on the click event of button the page should to redirected to the given url. But i am unable to do dat . pleae help me Regards Rahul rahul saini
Hi Give a method name for the onclick event of Button. You can add code behind for that button event. For example
protected void Button1_Onclick(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}Make sure that in your .aspx you have added OnClick event for the button. Method name can be anything but should be same as the code behind file. Hope this is clear.
Harini
-
there is a property of button commandname set commandname="Button1" and on the click of the button in itemcommand event of the datalist you can trace the button by its command name and can code accordingly.
-
Hi Give a method name for the onclick event of Button. You can add code behind for that button event. For example
protected void Button1_Onclick(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}Make sure that in your .aspx you have added OnClick event for the button. Method name can be anything but should be same as the code behind file. Hope this is clear.
Harini
-
Hi Ravi Thanks for rplying my post. Can u send me an example of dis. I am not getting ur point. I have assigned commandname. but wat to do next.... Please send me an example with code Thanks Rahul rahul saini
-
Hello Harini, Thanks for ur rply. But my button is in itemList in dataList. Thanks Rahul rahul saini
-
in the vb file
Private Sub datalist1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles datalist1.ItemCommand if e.commandname = "button1" then response.redirect("xyz.aspx") endif end sub
Hi Ravi It is not working. I have use following code in .aspx I have use following code in .vb Sub button_command(ByVal source As Object, ByVal e As DataListCommandEventArgs) Handles veiwJobDetails.ItemCommand If e.CommandName = "applyVacancy" Then Response.Redirect("wwww.jjjjdddd.com") End If End Sub But it not redirecting to dat url It is redirecting to the same page. Regards Rahul rahul saini
-
Hello every body, I want to use an button in item template of datalist and i want dat on the click event of button the page should to redirected to the given url. But i am unable to do dat . pleae help me Regards Rahul rahul saini
hi first set commandname property of datalist button and then write code on ItemCommand event Best regards Pathan
GOD HELP THOSE WHO HELP THEMSELVES
-
hi first set commandname property of datalist button and then write code on ItemCommand event Best regards Pathan
GOD HELP THOSE WHO HELP THEMSELVES
-
Hi Ravi It is not working. I have use following code in .aspx I have use following code in .vb Sub button_command(ByVal source As Object, ByVal e As DataListCommandEventArgs) Handles veiwJobDetails.ItemCommand If e.CommandName = "applyVacancy" Then Response.Redirect("wwww.jjjjdddd.com") End If End Sub But it not redirecting to dat url It is redirecting to the same page. Regards Rahul rahul saini