I need some help here

G

Guest

Hi,
I have a datagrid with 3 columns. One of the columns (quantity) is a
template column with dopdownlist. I want to be able to populate the
dropdownlist for each row with different data (based on the data in the first
column. I am trying this but doesn't work


Private Sub grdTranx_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdTranx.ItemDataBound

If e.Item.ItemType = ListItemType.EditItem And e.Item.ItemType <>
ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then

Dim dList As DropDownList = CType(e.Item.FindControl("DropDownList2"),
DropDownList)
Dim aList = New ArrayList

aList.Add(e.Item.Cells(0).Text.ToString) 'This is just a test. I will
actually be doing some checking in a database here and then returning a value
that will than be passed to the dropdownlist


dList.DataSource = aList

End If


End Sub

The gris is being bound at formload with

DataGrid1.DataSource = GetTrax(535) 'sqldatareader is returned here
DataGrid1.DataBind()

The columns are

name,type,quantity

Any ideas?
 
K

Karl Seguin

Chris,
Two thoughts.

First of all you aren't calling DataBind() on dList

it should be:
dList.DataSource = aList
dList.DataBind()


secondly, aList.Add(e.item.Cells(0).Text.ToString()) is suspect to me
because Cells(0) might not be what you think...maybe just try to hard code a
value for now in aList.Add("SomeValue") so you can see if the problem is
(a) with the binding (b) with fetching the cell value

Karl
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top