|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Trouble Filling DropDownList in Datagridcolumn 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 You should also check for:
e.Item.ItemType = ListItemType.AlternatingItem -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > 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
Checkbox in a datagrid always returns false
hosting app from pc Chart position RadioBNuttonList Problem query database, create control, display on page Validation on controls within a repeater Setting dropdownlist.selectedindex when entire datagrid is dynamic Labels Re: Serialize Style to save ViewState DHTML Behaviors (HTC) in a custom server control |
|||||||||||||||||||||||