B
Ben
Hi,
i have a detailsview in which i created a dropdownlist which is fed
programmatically.
The field (myfield) in the record contains integer 1.
With If DetailsView1.CurrentMode = DetailsViewMode.Edit, i get the error
(translated):
"selectedValue of myfield is wrong because it doesn't appear in the list
with items"
With If DetailsView1.CurrentMode = DetailsViewMode.Insert, no problem.
Why does i get an error when editing and not when inserting?
Thanks
Ben
<asp:TemplateField>
<EditItemTemplate>
<aspropDownList ID="mydd" runat="server" SelectedValue='<%#
Bind("myfield") %>' >
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
If DetailsView1.CurrentMode = DetailsViewMode.Edit Then
Dim dvr As DetailsViewRow
Dim dd1 As DropDownList
Dim i As Integer
Dim z As ListItem
For Each dvr In DetailsView1.Rows
dd1 = CType(dvr.FindControl("mydd"), DropDownList)
Next
For i = 1 To 10
z = New ListItem(i, i)
mydd.Items.Add(z)
Next
end if
end sub
i have a detailsview in which i created a dropdownlist which is fed
programmatically.
The field (myfield) in the record contains integer 1.
With If DetailsView1.CurrentMode = DetailsViewMode.Edit, i get the error
(translated):
"selectedValue of myfield is wrong because it doesn't appear in the list
with items"
With If DetailsView1.CurrentMode = DetailsViewMode.Insert, no problem.
Why does i get an error when editing and not when inserting?
Thanks
Ben
<asp:TemplateField>
<EditItemTemplate>
<aspropDownList ID="mydd" runat="server" SelectedValue='<%#
Bind("myfield") %>' >
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
If DetailsView1.CurrentMode = DetailsViewMode.Edit Then
Dim dvr As DetailsViewRow
Dim dd1 As DropDownList
Dim i As Integer
Dim z As ListItem
For Each dvr In DetailsView1.Rows
dd1 = CType(dvr.FindControl("mydd"), DropDownList)
Next
For i = 1 To 10
z = New ListItem(i, i)
mydd.Items.Add(z)
Next
end if
end sub