In my web page, I have a datagrid with a DropDownList.
The item collection for this list is dependent on an option selected by the user elsewhere on the page. The items for each option are stored in an xml file.
When the user selects an option, I get the values for that option from the xml file and populate a dropdownlist.
So far so good. But I can't work out how to bind this to the datagrid, to allow the user to select one of the items from the list.
Any help greatfully appreciated
Nenni M
Loading
Sony TPosted Nov 30, 2005, 1:32 AM
write this in codebehind. This reads the data from the database but u can use the readXml method of the dataset and popluate.
Function PopulateTitle() As DataSetPublic
Dim cn As New SqlConnection
Dim daPricing As SqlDataAdapter
Dim dsPricing As New DataSet
Dim TempList As New DropDownList
Dim myRow As DataRow
cn = New SqlClient.SqlConnection("ur connection string")
cn.Open()
daPricing = New SqlDataAdapter("SELECT TITLE, TITLE_ID FROM XYZ ORDER BY TITLE", cn)
daPricing.Fill(dsPricing)
PopulateTitle = dsPricing
dsPricing.Dispose()
daPricing.Dispose()
cn.Close()
End Function
write the following in .aspx
Method which is highlighted is as follows
Public Sub setTitle(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ddlTitle As DropDownList
ddlTitle = sender
If (Not ddlTitle Is Nothing And strServiceTitle <> "") Then
ddlTitle.ClearSelection()
ddlTitle.Items.FindByText(strServiceTitle).Selected = True
End If
End Sub
strServiceTitle is:
Public
Sub edit(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)strServiceTitle = CType(e.Item.FindControl("lbltitle"), Label).TextEnd Sub
Anuj ParyemalaniPosted Nov 22, 2005, 11:26 PM