G
Guest
I have a GridView with a couple of TemplateFields. When I click the update
link the Gridview returns to display mode with no errors but the data from
bound text fields or dropdown list isn't updated in the table. I'm stumped
and any help would be appreciated.
Thanks much.
My GridView:
<asp:GridView ID="VanListGridView" runat="server"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
CellPadding="3" GridLines="Horizontal"
DataSourceID="sdsVans" DataKeyNames="VanId"
AutoGenerateColumns="False" CssClass="waGridView"
AllowPaging="True" ShowFooter="true"
HorizontalAlign="Center">
<FooterStyle CssClass="waFooterStyle" />
<RowStyle CssClass="waRowStyle" />
<EmptyDataTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" CssClass="waLink"
NavigateUrl="VanDetail.aspx">New</asp:HyperLink>
The table is empty.</EmptyDataTemplate>
<SelectedRowStyle CssClass="waSelectedRowStyle" />
<PagerStyle CssClass="waPagerStyle" HorizontalAlign="Right" />
<HeaderStyle CssClass="waHeaderStyle" />
<AlternatingRowStyle CssClass="waAlternatingRowStyle" />
<Columns>
<asp:BoundField DataField="VanId" ReadOnly="true"
HeaderText="Id" SortExpression="VanId" />
<asp:BoundField DataField="VendorVanNo" HeaderText="Vendor
Van#" SortExpression="VendorVanNo" />
<asp:TemplateField HeaderText="VendorCode" ItemStyle-Width="60">
<ItemTemplate>
<asp:literal ID="Literal1" runat="server" Text='<%#
Eval("VendorCode") %>' />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddlVendors" runat="server"
DataSourceID="sdsVendors" DataTextField="VendorCode"
DataValueField="VendorCode" Width="80"
SelectedValue='<%# Bind("VendorCode") %>'>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status">
<ItemStyle Width="100" />
</asp:BoundField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server"
Checked='<%# Eval("Active") %>' CssClass="waCheckBox" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server"
Checked='<%# Bind("Active") %>' CssClass="waCheckBox" />
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StartDate" HeaderText="Start"
SortExpression="StartDate"
DataFormatString="{0:d}" HtmlEncode="false" />
<asp:BoundField DataField="EndDate" HeaderText="End"
SortExpression="EndDate" DataFormatString="{0:d}" HtmlEncode="false" />
</Columns>
</asp:GridView>
My Primary Vendors table SQL data source
<asp:SqlDataSource ID="sdsVans" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:myDB %>"
SelectCommand="SELECT VanId, VendorVanNo, VendorCode, StartDate,
EndDate, Status, Active FROM dbo.Vans order by VanId"
UpdateCommand="Update dbo.Vans set VendorVanNo=@VendorVanNo,
VendorCode=@VendorCode, Status=@Status, Active=@Active, StartDate=@StartDate,
EndDate=@EndDate where VanId=@VanId"
DeleteCommand="Delete from dbo.Vans where VanId=@VanId">
</asp:SqlDataSource>
DataSource for dropdownlist:
<asp:SqlDataSource ID="sdsVendors" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:cobbcc %>"
SelectCommand="SELECT VendorCode FROM dbo.Vendors order by VendorCode">
</asp:SqlDataSource>
link the Gridview returns to display mode with no errors but the data from
bound text fields or dropdown list isn't updated in the table. I'm stumped
and any help would be appreciated.
Thanks much.
My GridView:
<asp:GridView ID="VanListGridView" runat="server"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
CellPadding="3" GridLines="Horizontal"
DataSourceID="sdsVans" DataKeyNames="VanId"
AutoGenerateColumns="False" CssClass="waGridView"
AllowPaging="True" ShowFooter="true"
HorizontalAlign="Center">
<FooterStyle CssClass="waFooterStyle" />
<RowStyle CssClass="waRowStyle" />
<EmptyDataTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" CssClass="waLink"
NavigateUrl="VanDetail.aspx">New</asp:HyperLink>
The table is empty.</EmptyDataTemplate>
<SelectedRowStyle CssClass="waSelectedRowStyle" />
<PagerStyle CssClass="waPagerStyle" HorizontalAlign="Right" />
<HeaderStyle CssClass="waHeaderStyle" />
<AlternatingRowStyle CssClass="waAlternatingRowStyle" />
<Columns>
<asp:BoundField DataField="VanId" ReadOnly="true"
HeaderText="Id" SortExpression="VanId" />
<asp:BoundField DataField="VendorVanNo" HeaderText="Vendor
Van#" SortExpression="VendorVanNo" />
<asp:TemplateField HeaderText="VendorCode" ItemStyle-Width="60">
<ItemTemplate>
<asp:literal ID="Literal1" runat="server" Text='<%#
Eval("VendorCode") %>' />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddlVendors" runat="server"
DataSourceID="sdsVendors" DataTextField="VendorCode"
DataValueField="VendorCode" Width="80"
SelectedValue='<%# Bind("VendorCode") %>'>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status">
<ItemStyle Width="100" />
</asp:BoundField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server"
Checked='<%# Eval("Active") %>' CssClass="waCheckBox" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server"
Checked='<%# Bind("Active") %>' CssClass="waCheckBox" />
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StartDate" HeaderText="Start"
SortExpression="StartDate"
DataFormatString="{0:d}" HtmlEncode="false" />
<asp:BoundField DataField="EndDate" HeaderText="End"
SortExpression="EndDate" DataFormatString="{0:d}" HtmlEncode="false" />
</Columns>
</asp:GridView>
My Primary Vendors table SQL data source
<asp:SqlDataSource ID="sdsVans" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:myDB %>"
SelectCommand="SELECT VanId, VendorVanNo, VendorCode, StartDate,
EndDate, Status, Active FROM dbo.Vans order by VanId"
UpdateCommand="Update dbo.Vans set VendorVanNo=@VendorVanNo,
VendorCode=@VendorCode, Status=@Status, Active=@Active, StartDate=@StartDate,
EndDate=@EndDate where VanId=@VanId"
DeleteCommand="Delete from dbo.Vans where VanId=@VanId">
</asp:SqlDataSource>
DataSource for dropdownlist:
<asp:SqlDataSource ID="sdsVendors" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:cobbcc %>"
SelectCommand="SELECT VendorCode FROM dbo.Vendors order by VendorCode">
</asp:SqlDataSource>