Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid: Can't get onprerender to work 1

Status
Not open for further replies.

olypost

Programmer
Apr 15, 2005
43
US
I have a datagrid w/several controls, one of which is a dropdownlist. I can databind the list, select one and save, no problem.

My problem is: When the page loads for the first time, I'd like my dropdownlists to default to the value saved for that particular column for each record shown in the datagrid. I can't get the subroutine in the code-behind that's called via onprerender to reference a value from my datagrid that's used for the findbyvalue.

Public Sub SetDropDownIndex1(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByValue(my_id))
End Sub

If there's just one record, I can set my_id easily, but in my case I have 15 records to display. This SetDropDownIndex1 is called from my onprerender in the ddl.

Also tried selectedindex to call a function instead of onprerender, but for some reason I couldn't reference the dropdownlist control in the code-behind... Is this because the ddl is within the datagrid? Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top