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>
<asp
arameter Name="datbegin" Type="Integer" />
</InsertParameters>
</asp:SqlDataSource>
<asp
etailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" DefaultMode="Insert" >
<Fields>
<asp:TemplateField HeaderText="datbegin">
<InsertItemTemplate>
<asp
ropDownList ID="begdat" runat="server" DataTextField="datbegin" >
</asp
ropDownList>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp
etailsView>
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>
<asp
![Stick Out Tongue :P :P](/styles/default/custom/smilies/tongue.gif)
</InsertParameters>
</asp:SqlDataSource>
<asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
DataKeyNames="id" DataSourceID="SqlDataSource1" DefaultMode="Insert" >
<Fields>
<asp:TemplateField HeaderText="datbegin">
<InsertItemTemplate>
<asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
</asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
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