Link to home
Create AccountLog in
Avatar of Robb Hill
Robb HillFlag for United States of America

asked on

Setting the index value of a dropdownlist when its created

I have a dropdownlist in asp.net 2.0.

This dropdownlist is populated from a SQLDATASOURCE control.

When the control is created the 1st item in the list does not let me click on it.  I am pasting the code below.  Please help.

<asp:SqlDataSource ID="TemplateSource" runat="server"
     ConnectionString="<%$  ConnectionStrings:NewDMSConnectionString %>"
     SelectCommand="select * from Template inner join Templatedetail on tmptype = RepType order by tmpName"
     DataSourceMode="DataReader"/>

<asp:DropDownList id="TemplateList" Runat="Server"
  DataSourceID="TemplateSource"
  DataTextField="tmpName"
  DataValueField="tmpID"
  AutoPostBack="True"  
  OnSelectedIndexChanged="GetTemplateData"/><br/>
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Robb Hill

ASKER

This is not working.

I have this drop down list being rendered inside a view control.
The values in the dropdown list are being generated from asp datacontrol and are not being populated from any vb event.  I tried using your code in on load...and from the onclick event of the button on the previous page....and it doesnt seem to affect the dropdownlist....

How would you suggest I apply this code...?
ahh..I used the on Pre render event to fire this change....

Thanks for the help