|
Question : Set SelectedValue of DropdownList in EditItemTemplate of Gridview. Visual Studio 2005.
|
|
Set SelectedValue of DropdownList in EditItemTemplate of Gridview. Visual Studio 2005.
When the gridview row Edit button is clicked, the DropDownList displays and is set to the selected value of the first row of the DropDownList SQL statement.
I need to set the selected value to the old value. The label control of the Gridview contains the old value.
How can I set the selected value to the old value ?
This is my code:
Protected Sub grdPurchases_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grdPurchases.RowEditing
Dim intRowIndex As Integer
intRowIndex = e.NewEditIndex 'Row being edited 'Set selected row to the row being edited grdPurchases.SelectedIndex = intRowIndex
Dim cboBrokerAccount As DropDownList = CType(grdPurchases.Rows(intRowIndex).FindControl("cboBrokerAccount"), DropDownList)
dscBrokerAccount.SelectCommand = _ "SELECT [AccountID], [AccountKey] FROM [Account] " _ & "WHERE [UserID] ='" & txtGridParam.Text & "' ORDER BY [AccountID]"
'Set the selected value of the DropDownList to the OldValue ???? End Sub
|
|
Answer : Set SelectedValue of DropdownList in EditItemTemplate of Gridview. Visual Studio 2005.
|
|
Looks like to data your binding to doesn't have a column ''AccountID''. I'd start looking there.
If all else fails email me the aspx and the table stucture for your data and I'll take a look at it.
Robert Fidler Springfield, Missouri
email address is: rfidler at kpmtechnology dot com
|
|
|