itemdatabound dropdownlist - not bound

Results 1 to 2 of 2

Thread: itemdatabound dropdownlist - not bound

  1. #1
    Join Date
    Dec 1969

    Default itemdatabound dropdownlist - not bound

    I have a problem that I can&#039;t seem to get around... bear with me I am fairly new to this .net lark!<BR><BR>I have a datagrid.<BR>In that datagrid I have a date (databound)<BR>I have said date in an item template<BR>I want to have an edititemtemplate dropdown list.<BR>The source for this edit dropdownlist is not contained within my db.<BR>I essentially want to increment and add list items.<BR>Now i tried to give the edititemtemplate an id and populate the list during the itemdatabound event but the code fell over as it couldn&#039;t find the list<BR><BR>The (shortened version) code i was using was along the lines of:<BR><BR>Sub date_add(sender as object, e as datagrideventargs)<BR><BR>If e.item.itemtype = ListItemType.Item or e.Item.ItemType = ListItemType.AlternatingItem then<BR><BR>dim cddlist as dropdownlist<BR><BR>dim i as integer<BR>Do Until i &#062; 31<BR>Dim c_day as new listitem()<BR>c_day.text = String.Format("{0:00}",i)<BR>c_day.value = i<BR>cddlist = e.Item.FindControl("Client_Day")<BR>cddlist.Items. Add(c_day)<BR>i = i + 1<BR>Loop<BR><BR>End Sub<BR><BR>This worked when the Client_Day drop down list was an itemtemplate but not when an edititemtemplate.<BR><BR>So in short - how can I populate a drop down list in an edititemtemplate - without using a db datasource - all the examples I find on the net are using database sources to populate and I can&#039;t do that in this instance without creating a table... which I&#039;d rather not do.<BR><BR>I am going to be the most grateful person in the world if someone can point me in the right direction.

  2. #2
    Join Date
    Dec 1969

    Default RE: itemdatabound dropdownlist - not bound

    You are looking at the wrong event. When you are trying to do something dynamic when the DataGrid is put into edit mode, you would create an event handler for the EditCommand Event, not the ItemDataBound Event.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts