Hi
There is a gridview with a hiddenfield and a dropdownlist in templates. I have to find them from code-behind. I have the solution but don't understand everything.
1) from event GridView1_RowDataBound: why does this not work: sv = sender.FindControl("HiddenField1") ?
2) from event d2_SelectedIndexChanged: why do I have to use 'sender' here like dd2 = sender.FindControl("HiddenField1") and not simply dd2 = FindControl("HiddenField1") ?
'Sender' refers to the object which raised the event, but this is as if 'HiddenField1' was inside the dropdownlist.
Thanks
-----
Friend sv As HiddenField
Friend dd2 As DropDownList
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
sv = e.Row.FindControl("HiddenField1")
dd2 = e.Row.FindControl("dd2")
...
Protected Sub dd2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
sv = sender.FindControl("HiddenField1")
dd2 = sender.FindControl("dd2")
End Sub
Valerie MeunierPosted Jul 26, 2022, 9:30 PM
Jignesh KumarPosted Jul 26, 2022, 1:16 PM