B
Ben
Hi,
i defined a dropdownlist in a detailsview but the values are provided
programmatically. This works.
The default mod of the detailsview is INSERT.
My problem is that the selected value of the user is not inserted in the
table. What i don't know is how to link the selected value to the right
field?
With a normal field, i use something
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("myfield")
%>'></asp:TextBox>
But with a dropdownlist?
Thanks for help.
Ben
Here my code:
aspx
----
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
InsertCommand="INSERT INTO [mytable] ([datbegin]) VALUES
(@datbegin)">
<InsertParameters>
<asparameter Name="datbegin" Type="Integer" />
</InsertParameters>
</asp:SqlDataSource>
<aspetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" DefaultMode="Insert" >
<Fields>
<asp:TemplateField HeaderText="datbegin">
<InsertItemTemplate>
<aspropDownList ID="begdat" runat="server" DataTextField="datbegin" >
</aspropDownList>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</aspetailsView>
code-behind
-----------
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
'here the code to find the dropdownlist in the template and to
fill it with values
' this works so i didn't show the code here
'....
end sub
i defined a dropdownlist in a detailsview but the values are provided
programmatically. This works.
The default mod of the detailsview is INSERT.
My problem is that the selected value of the user is not inserted in the
table. What i don't know is how to link the selected value to the right
field?
With a normal field, i use something
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("myfield")
%>'></asp:TextBox>
But with a dropdownlist?
Thanks for help.
Ben
Here my code:
aspx
----
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
InsertCommand="INSERT INTO [mytable] ([datbegin]) VALUES
(@datbegin)">
<InsertParameters>
<asparameter Name="datbegin" Type="Integer" />
</InsertParameters>
</asp:SqlDataSource>
<aspetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" DefaultMode="Insert" >
<Fields>
<asp:TemplateField HeaderText="datbegin">
<InsertItemTemplate>
<aspropDownList ID="begdat" runat="server" DataTextField="datbegin" >
</aspropDownList>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</aspetailsView>
code-behind
-----------
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
'here the code to find the dropdownlist in the template and to
fill it with values
' this works so i didn't show the code here
'....
end sub