It is very funny because I use the same structure of code in 2 different projects and 1 one of them works fine but the other will just not even execute.
Here is the asp.net code (BulkEditGridview is an extended control that uses gridview as base control so it basically works the same way)
<cc1:BulkEditGridView ID="BulkEditGridView1" runat="server" DataKeyNames="id"
AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
DataSourceID="titlesSqlDataSource" EnableInsert="False"
EnableModelValidation="True" SaveButtonID="Button1">
<Columns>
<asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />
<asp:BoundField DataField="siteid" HeaderText="SiteID" ReadOnly="True"
SortExpression="siteid" />
<asp:BoundField DataField="block" HeaderText="Block" SortExpression="block" >
<ControlStyle Width="50px" />
<HeaderStyle Width="50px" />
<ItemStyle Width="50px" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
Button1 postbacks and even executes BulkEditGridView1.Save();
Here is the Datasource and Button code:
<asp:SqlDataSource ID="titlesSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:xxxx %>"
SelectCommand="sp_getBottomLinksTitles" SelectCommandType="StoredProcedure"
UpdateCommand="sp_updateBlockTitle" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter DefaultValue="1" Name="siteid" SessionField="siteid"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="title" Type=String />
<asp:Parameter Name="id" Type=Int32 />
<asp:Parameter Name="block" Type=Int32 />
</UpdateParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" />
That code is the one not working, however this one works like a charm:
<cc1:BulkEditGridView ID="GridViewExistingInvoices" SaveButtonID="AcceptButton" DataKeyNames=id runat="server" DataSourceID="InvoicesSqlDatasource" Font-Bold="False" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical" Width="915px" AllowSorting="True">
<FooterStyle BackColor="#CCCCCC" />
<EmptyDataTemplate> No Invoices to make</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="date" ItemStyle-Font-Size="11px" HeaderText="Invoice Date" SortExpression="date" DataFormatString="{0:dd-MMM-yyyy}" ItemStyle-VerticalAlign="Top">
<HeaderStyle Width="80px" />
<ItemStyle Width="80px" Font-Size="11px"/>
<ControlStyle Width="80px" Font-Size="11px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:TextBox Text='<%# Bind("Amount1") %>' Font-Size="11px" Width="60px" runat=server ID="amount">
</asp:TextBox><br/>
<asp:TextBox Text='<%# Bind("Amount2") %>' Font-Size="11px" Width="60px" runat=server ID="TextBox1">
</asp:TextBox><br/>
<asp:TextBox Text='<%# Bind("Amount3") %>' Font-Size="11px" Width="60px" runat=server ID="TextBox2">
</asp:TextBox><br/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Payment Due">
<ItemTemplate>
<asp:TextBox Text='<%# Bind("payment_Due") %>' Font-Size="11px" Width="70px" runat=server ID="tdue1">
</asp:TextBox><br/>
<asp:TextBox Text='<%# Bind("due2") %>' Font-Size="11px" Width="70px" runat=server ID="tdue2">
</asp:TextBox><br/>
<asp:TextBox Text='<%# Bind("due3") %>' Font-Size="11px" Width="70px" runat=server ID="tdue3">
</asp:TextBox><br/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Amount" ItemStyle-Font-Size="11px" HeaderText="Total Amount" SortExpression="Amount" DataFormatString="{0:c}" ItemStyle-VerticalAlign="Top" >
<HeaderStyle Width="60px" />
<ItemStyle Width="60px" Font-Size="11px"/>
<ControlStyle Width="60px" Font-Size="11px" />
</asp:BoundField>
<asp:BoundField DataField="T" HeaderText="T" ItemStyle-Font-Size="11px" SortExpression="T" ItemStyle-VerticalAlign="Top">
<HeaderStyle Width="25px" />
<ItemStyle Width="25px" Font-Size="11px"/>
<ControlStyle Width="40px" Font-Size="11px"/>
</asp:BoundField>
<asp:TemplateField HeaderText="Invoice Description">
<ItemTemplate>
<asp:TextBox Text='<%# Bind("Description") %>' Font-Size="11px" Width="200px" TextMode=MultiLine Height=50px runat=server ID="tDescription">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comments">
<ItemTemplate>
<asp:TextBox Text='<%# Bind("Comments") %>' Font-Size="11px" Width="190px" TextMode=MultiLine Height=50px runat=server ID="tComments">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="isblack" ItemStyle-Font-Size="11px" HeaderText="B" SortExpression="isblack" >
<HeaderStyle Width="20px" />
</asp:CheckBoxField>
<asp:CheckBoxField DataField="plusiva" ItemStyle-Font-Size="11px" HeaderText="+IVA" SortExpression="plusiva" >
<HeaderStyle Width="20px" />
</asp:CheckBoxField>
<asp:HyperLinkField DataNavigateUrlFields="url" ItemStyle-Font-Size="11px" HeaderText="Print" Text="Print" >
<HeaderStyle HorizontalAlign="Left" Width="50px" />
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="urlDeleteP" ItemStyle-Font-Size="11px" Text="Delete" />
</Columns>
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
</cc1:BulkEditGridView>
<asp:SqlDataSource ID="InvoicesSqlDatasource" runat="server" ConnectionString="<%$ ConnectionStrings:xxxConnectionString %>"
SelectCommand="SELECT payment.id,'Not assigned' id1,plusiva,payment.id, payment.[date],CAST( [totalAmount] as decimal(10,2)) as amount,amount as amount1,amount2,amount3,due2,due3, [payment_due], payment.[comments],paymentform AS T , [isblack],'view_invoice.aspx?id='+cast(payment.id as nvarchar(10)) as url, 'delete_preInvoice.aspx?id='+cast(payment.id as nvarchar(10)) as urlDeleteP , Description FROM [payment],lead WHERE (payment.clientid = @id AND payment.clientid=lead.id AND invoiceId is null) ORDER BY [date]"
UpdateCommand="sp_updateInvoiceN" UpdateCommandType=StoredProcedure>
<SelectParameters>
<asp:QueryStringParameter DefaultValue="1" Name="id" QueryStringField="id" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="date" Type=DateTime/>
<asp:Parameter Name="payment_due" Type=DateTime/>
<asp:Parameter Name="comments" type=String />
<asp:Parameter Name="Description" type=String />
<asp:Parameter Name="amount" type=Double />
<asp:Parameter Name="id" type=String />
<asp:Parameter Name="isBlack" type=Boolean />
<asp:Parameter Name="plusiva" type=Boolean />
<asp:Parameter Name="due2" Type=DateTime/>
<asp:Parameter Name="due3" Type=DateTime/>
<asp:Parameter Name="amount2" type=Double />
<asp:Parameter Name="amount3" type=Double />
<asp:Parameter Name="amount1" type=Double />
</UpdateParameters>
</asp:SqlDataSource>
The structure is the same, using the same control, same way of update, Datakeynames is there in both, both executes the same thing on button click event, it is a bit weird, using sql server profiler I can see it doenst execute the updatecommand, and testing the stored procedure from Sql server management studio it works fine.
It is not a Connection problem either because the selectCommand works, and it loads the information from the DB.
Any ideas??