DropDownList in DataGrid: DataSource is an ArrayLi

inciongowu

New Member
Hello,<BR><BR>I have placed a few DropDownList controls in a DataGrid. Some have DataReaders as their DataSource, and they are working fine. I have a few that I want to populate with an array instead of a DataReader, but I can't seem to get this working. I experimented with a DropDownList that is not in a DataGrid, set it's DataSource property to my array, and after DataBind() it fills as expected. Can anyone tell me, or point me to an article/example that will show me, how to make this work in my DataGrid?<BR><BR>Thank You!<BR><BR><BR><BR>In "X.aspx":<BR>-----------------<BR>?<BR><EditItemTemplate><BR>??? <asp:DropDownList id="ddlSun" DataValueField="Sun" DataTextField="Sun" DataSource='<%#ListOfHours()%>' Runat="server"></asp:DropDownList><BR></EditItemTemplate><BR><BR>In "X.aspx.vb":<BR>-------------------<BR>?<BR>Function ListOfHours() As ArrayList<BR>??? Dim HourList As ArrayList = New ArrayList()<BR>??? Dim i As Int16<BR> For i = 0 To 23<BR> HourList.Add(i)<BR> HourList.Add(i + 0.25)<BR> HourList.Add(i) + 0.5)<BR> HourList.Add(i + 0.75)<BR> Next<BR> HourList.Add(24.0)<BR>??? Return HourList <BR>End Function<BR>Hey Chris, <BR><BR>You say it doesn't work, but what does it do? Any errors or does it just do nothing?I'm sorry, I knew better than to leave that out!<BR><BR>Error when binding the grid: "DataBinder.Eval: 'System.String' does not contain a property with the name Sun."<BR><BR>I think it's having a problem with "DataValueField="Sun""?<BR>
 
Back
Top