D
David Londeck
The following code will only populate every row for the DropDownList control
column in the datagrid instead of every row where the DropDownList appears
in the DataGrid for a particular column. Any ideas on why?
Private Sub dgAssignSalesReptoIMEI_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgAssignSalesReptoIMEI.ItemDataBound
If dtSalesRep Is Nothing Then
' This will make a trip to the Database
dtSalesRep = FilldgDropDownList()
End If
If e.Item.ItemType = ListItemType.Item Then
Dim DRV As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim DropDown As String = DRV("REPID")
Dim ddl As DropDownList = _
CType(e.Item.FindControl("ddlSalesRep"), DropDownList)
Dim Item As ListItem
' Fill grid
' if dtSalesRep is globally defined then we save the trip to the
database
ddl.DataSource = dtSalesRep
ddl.DataTextField = "RepName"
ddl.DataValueField = "RepID"
ddl.DataBind()
ddl.Items.Insert(0, "Unassigned")
ddlDefaultValue.text = drv.("RepID")
Item = ddl.Items.FindByValue(DropDown)
' If this item is not null then select the item
If Not Item Is Nothing Then Item.Selected = True
End If
End Sub
column in the datagrid instead of every row where the DropDownList appears
in the DataGrid for a particular column. Any ideas on why?
Private Sub dgAssignSalesReptoIMEI_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgAssignSalesReptoIMEI.ItemDataBound
If dtSalesRep Is Nothing Then
' This will make a trip to the Database
dtSalesRep = FilldgDropDownList()
End If
If e.Item.ItemType = ListItemType.Item Then
Dim DRV As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim DropDown As String = DRV("REPID")
Dim ddl As DropDownList = _
CType(e.Item.FindControl("ddlSalesRep"), DropDownList)
Dim Item As ListItem
' Fill grid
' if dtSalesRep is globally defined then we save the trip to the
database
ddl.DataSource = dtSalesRep
ddl.DataTextField = "RepName"
ddl.DataValueField = "RepID"
ddl.DataBind()
ddl.Items.Insert(0, "Unassigned")
ddlDefaultValue.text = drv.("RepID")
Item = ddl.Items.FindByValue(DropDown)
' If this item is not null then select the item
If Not Item Is Nothing Then Item.Selected = True
End If
End Sub