----------------------------------------------------------- New Message on BDOTNET
----------------------------------------------------------- From: DotNetSaavy (Mr.BabuRaj) Message 1 in Discussion Hi, I have created a webpage which has a datagrid control.The datagrid control has a DropDownList in the <EditItemTemplate> ,on clicking the edit link button on my datagrid I am populating the values for the dropdownlist from the database. I am also setting the selectedindex attribute of the dropdownlist to get the value selected in the edit mode.The code in my aspx page for the dropdownlist is as follows <asp:DropDownList id="ddAge" runat="server" DataTextField="SupplierID" DataValueField="SupplierID" DataSource='<%# PopulateDropDownList()%>' SelectedIndex='<%# getAge(DataBinder.Eval(Container.DataItem, "age"))%>'></asp:DropDownList> The functions PopulateDropDownList() and getAge in the code behind is as follows Protected Function PopulateDropDownList() Dim strSQL As String Dim Con As New SqlConnection(strConn) Con.Open() strSQL = "SELECT supplierid from suppliers order by 1" Dim Com As New SqlCommand(strSQL, Con) Dim rdr As SqlDataReader = Com.ExecuteReader() PopulateDropDownList = rdr End Function Protected Function getAge(ByVal selval As Integer) As Integer Dim i As Integer = 0 Dim valDB As Integer Dim crdr As SqlDataReader crdr = PopulateDropDownList() If crdr.HasRows Then While crdr.Read valDB = crdr(0) If CInt(valDB) = selval Then Return getAge = CInt(selval) End If End While End If getAge = 0 End Function The code to get the value selected in the dropdownlist is not working.Can you let me know why the value is not getting selected in the edit mode. ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/BDotNet/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
