how do i redirect from ItemDataBound event of repeater to another page by passing values
i have a repeater control and on ItemDataBound event i want fetch values in the repeater control and redirect to another page by passing those values as parameter. i have written the following code
Protected Sub rptData_ItemDataBound(ByVal source As Object, ByVal开发者_开发问答 e As RepeaterItemEventArgs)
Dim content As String = ""
Dim url As String = ""
Dim lbl1 As Label = TryCast(e.Item.FindControl("content"), Label)
Dim lbl2 As Label = TryCast(e.Item.FindControl("url"), Label)
content = lbl1.Text
url = lbl2.Text
Dim btn As LinkButton = CType(e.Item.FindControl("glossary"), LinkButton)
btn.Attributes.Add("onclick", "Response.Redirect('glossary.aspx?cont=' + content + 'url=' + url)return true;")
end su
just modifiy below line of code because there is an error because of this only
there is no need of respose.redirect
you need to redirect so you use javascript location
object as i shown below
btn.Attributes.Add("onclick", "window.location = 'glossary.aspx?cont=" + content + "&url=" + url + "';")
or
just set prostbackurl property of link button
btn.PostBackUrl= "glossary.aspx?cont=" + content + "&url=" + url ;
An alternate way to do this is to create a new event handler routine, pass the information to the Event Args and hook LinkButton btn to the event handler, then you can use the Response.Redirect.
精彩评论