1
Answer

Database dont update from gridview templatefield

Hello

I have i Gridview with a templatefield. Calender shows on edit for users to be able to change date. It does not work. Thx for help. Best regards Halvard

GRIDVIEW

<asp:GridView ID="GridView7" runat="server" DataSourceID="SqlDataSource6" EnableModelValidation="True" AllowSorting="True" AutoGenerateColumns="False" >

<Columns>

<asp:CommandField ShowEditButton="True" />

<asp:TemplateField HeaderText="Förfallodatum" SortExpression=" Förfallodatum" >

<EditItemTemplate>

<asp:Calendar ID="Calendar1" runat="server" VisibleIndex="4"

SelectedDate='<%# Bind("Forfallodatum") %>'

VisibleDate='<%# Eval("Forfallodatum") %>'>

</asp:Calendar>

<asp:TextBox ID="TextBox3" runat="server"

Text='<%# Bind("Forfallodatum") %>'></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>

<asp:TextBox ID="TextBox3" runat="server"

Text='<%# Eval("Forfallodatum") %>'></asp:TextBox>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

SQL:

UpdateCommand="UPDATE faktura SET Forfallodatum = ? WHERE nr = ?

UPDATEPARAMETER 
 

<UpdateParameters>

<asp:ControlParameter ControlID="TextBox3"

Name="Forfallodatum"

Type="DateTime" />

<asp:Parameter Name="nr" Type="Int32" />

</UpdateParameters>

IN .CS PAGE_LOAD
 

if (!Page.IsPostBack)

{

GridView7.DataBind();

}

 
 
Answers (1)