RE: DataGridView with databound combobox
- From: Jakob Lithner <jaklithn@xxxxxxxxxxxxxxxx>
- Date: Thu, 23 Mar 2006 12:49:38 -0800
Thanks Phillip, I appreciate your effort!
1) I tried hard to get this working but one remaining stumblingblock is this
line:
<asp:DropDownList ID="cboActivityTime" runat="server"
DataSourceID="objTimes" DataValueField="TimeShow" DataTextField="TimeShow"
SelectedValue='<%# Bind("ActivityTime") %>' ></asp:DropDownList>
It will cause this error:
"'cboActivityTime' has a SelectedValue which is invalid because it does not
exist in the list of items.
Parameter name: value"
Possible workaoround?
Your solution obviously works. What is the difference? My ObjectDatasource
retrieves a DataView, will that be a problem?
2) And I am still VERY eager to manipulate the DropDownList in code behind
(Load, set SelectedValue, etc). I am much more used to plain code than these
ObjectSource objects, and find it more flexible.
In the GridView RowEditing Event I can easily get hold of the Literal
control of the TemplateField. Is it impossible to get hold of the
DropDownList control in a similar way?
<asp:TemplateField HeaderText="ActivityTime">
<ItemTemplate>
<asp:Literal ID="litActivityTime" runat="server"
Text='<%# Eval("ActivityTime") %>'></asp:Literal>
</ItemTemplate>
<EditItemTemplate>
<asp:ObjectDataSource ID="objTimes" runat="server"
TypeName="SKF.BusinessLogic.StaticInfo"
SelectMethod="GetNormalTimes"
DataObjectTypeName="SKF.BusinessLogic.StaticInfo"></asp:ObjectDataSource>
<asp:DropDownList ID="cboActivityTime" runat="server"
DataSourceID="objTimes" DataValueField="TimeShow" DataTextField="TimeShow"
SelectedValue='<%# Bind("ActivityTime") %>' ></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
Protected Sub grdActivity_RowEditing(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewEditEventArgs) Handles
grdActivity.RowEditing
Dim grd As GridView
Dim row As GridViewRow
Dim lit As New Literal
Dim cbo As DropDownList
grd = DirectCast(sender, GridView)
row = DirectCast(sender, GridView).Rows(e.NewEditIndex)
lit = DirectCast(row.FindControl("litActivityTime"), Literal)
'cbo = DirectCast(row.FindControl("cboActivityTime"), DropDownList)
End Sub
.
- Follow-Ups:
- RE: DataGridView with databound combobox
- From: Phillip Williams
- RE: DataGridView with databound combobox
- References:
- RE: DataGridView with databound combobox
- From: Phillip Williams
- RE: DataGridView with databound combobox
- Prev by Date: Re: Casini, IIS run code differently
- Next by Date: Re: How do I catch unhandled exceptions
- Previous by thread: RE: DataGridView with databound combobox
- Next by thread: RE: DataGridView with databound combobox
- Index(es):
Relevant Pages
|