Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > (v2003) Datagrid Dropdownlist Edit Problems

Thread Tools

(v2003) Datagrid Dropdownlist Edit Problems

Posts: n/a
I'm trying to edit data in a datagrid through a dropdown list with different
id/text values. The problem comes in when I click the edit button & nothing
appears to be happening. Did I do something wrong in the EditItemTemplate
or should I be binding, somehow, separately in the vb code? Please view my
code, below, and the notes in green for clarification of what I've done, and
what is/is not working, here. Thanks in advance.

<aspataGrid id="dgItems" runat="server" CssClass="tablestandardsettings"
BorderColor="Navy" AutoGenerateColumns="False">


<asp:TemplateColumn HeaderText="Available Items">

<ItemTemplate> 'This works

id="lbItem" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,
"ItemName") %>' />


<EditItemTemplate> 'This
does not work

id="cboItem" runat="server"

DataSource='<%# dvItems %>'






<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="OK"
CancelText="Cancel" EditText="Edit" />

<asp:ButtonColumn Text="Delete" CommandName="Delete"/>




'I bind & display the datagrid here, when a user checks a

'box to maintain the items - THIS PART WORKS

'The grid is displayed, & the items show in the item column


Private Sub chkItems_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles chkItems.CheckedChanged

If Me.chkItems.Checked Then


Me.pnlItemMaintenance.Visible = True


Me.pnlItemMaintenance.Visible = False

End If

End Sub


'However, when edit is selected, the dataview is populated,

'but the row never opens in edit mode (the drop-down list

'and Update/Cancel Buttons are not displayed/opened).


Private Sub dgItems_EditCommand(ByVal source As Object, ByVal e As _

System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles

BindItemsDropDownList() 'Populates dvItems - This works

Dim lblItemLabel As Label = e.Item.FindControl("lblItem")

Session("OldItem") = lblItemLabel.Text


'Tracing accurately shows information retrieved from the Dataview,

'That should be bound to the data grid's dropdownlist


Trace.Write("Current Item: " & Session("OldItem"))

Trace.Write("ID: " & CStr(dvItems.Table.Rows(e.Item.ItemIndex)("ItemID" )))

Trace.Write("Item: " &
CStr(dvItems.Table.Rows(e.Item.ItemIndex)("ItemNam e")))




'1) Setting the properties of the actual cboItem

'dropdownlist in the grid: The following 2 lines generate

'an instantiation error, but if I create an instance, then

'it's separate from the actual item in the grid.


'Dim cboItemList As DropDownList = e.Item.FindControl("cboItem")

'cboItemList.SelectedItem.Text = lblItemLabel.Text


'2) Row never opens for editing (even with above 2 lines

' removed):


Me. dgItems.EditItemIndex = e.Item.ItemIndex

End Sub

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM
Edit All Function for DataGrid, and Moving the Edit Function in a DataGrid Schultz ASP .Net 3 02-14-2005 04:47 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM
copying value of DDL in a Datagrid "pre-edit command" to value in "post edit command" San Diego Guy ASP .Net 0 08-07-2003 08:59 PM