Datagrid DropDownlist example

G

GG

HI

I am working with the following Microsoft sample code found at http://msdn.microsoft.com/library/d...y/en-us/dnaspp/html/creatingcustomcolumns.asp

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBoun
If e.Item.ItemType = ListItemType.EditItem The
Dim DRV As DataRowView = CType(e.Item.DataItem, DataRowView
Dim CurrentShip As String = DRV("ShipVia"
Dim DDL As DropDownList =
CType(e.Item.Cells(4).Controls(1), DropDownList
Dim SQL As String =
"SELECT ShipperID, CompanyName FROM Shippers ORDER BY ShipperID
Dim DA As SqlDataAdapter = New SqlDataAdapter(SQL, ConnStr
Dim DS As New DataSe
Dim item As ListIte
DA.Fill(DS, "Shippers"
DDL.DataSource = DS.Tables("Shippers").DefaultVie
DDL.DataTextField = "CompanyName
DDL.DataValueField = "ShipperID
DDL.DataBind(
item = DDL.Items.FindByValue(CurrentShip
If Not item Is Nothing Then item.Selected = Tru
End I
End Su

When it gets to the line "Dim DDL As DropDownList =
CType(e.Item.Cells(4).Controls(1), DropDownList)" it says the index is out of range even though I have the specified columns of data including the edit column

Any help is appreciated

Thanks
G
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top