I have a gridview which contains data from a table, when I click in a row that has every field with data I can update without problems but when I click on update in one that has empty field doesn't update anything, how can I solve this?
This is my gridview code:
This is my gridview code:
Code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan"
BorderWidth="1px" CellPadding="2" DataKeyNames="Cod" DataSourceID="SqlDataSourceMod"
Font-Size="11px" ForeColor="Black" GridLines="None" PageSize="50" Style="position: static">
<FooterStyle BackColor="Tan" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Cod" HeaderText="Cod" ReadOnly="True" SortExpression="Cod" />
<asp:BoundField DataField="Modulo" HeaderText="Modulo" SortExpression="Modulo" />
<asp:BoundField DataField="Padre" HeaderText="Padre" SortExpression="Padre" />
<asp:BoundField DataField="Imagen" HeaderText="Imagen" SortExpression="Imagen" />
<asp:CheckBoxField DataField="A" HeaderText="A" SortExpression="A" />
<asp:CheckBoxField DataField="R" HeaderText="R" SortExpression="R" />
<asp:CheckBoxField DataField="V" HeaderText="V" SortExpression="V" />
<asp:BoundField DataField="Enlace" HeaderText="Enlace" SortExpression="Enlace" />
</Columns>
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceMod" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:SIPConnectionString %>" DeleteCommand="DELETE FROM [Modulos] WHERE [Cod] = @original_Cod AND [Modulo] = @original_Modulo AND [Padre] = @original_Padre AND [Imagen] = @original_Imagen AND [A] = @original_A AND [R] = @original_R AND [V] = @original_V AND [Enlace] = @original_Enlace"
InsertCommand="INSERT INTO [Modulos] ([Modulo], [Padre], [Imagen], [A], [R], [V], [Enlace]) VALUES (@Modulo, @Padre, @Imagen, @A, @R, @V, @Enlace)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [Modulos]"
UpdateCommand="UPDATE [Modulos] SET [Modulo] = @Modulo, [Padre] = @Padre, [Imagen] = @Imagen, [A] = @A, [R] = @R, [V] = @V, [Enlace] = @Enlace WHERE [Cod] = @original_Cod AND [Modulo] = @original_Modulo AND [Padre] = @original_Padre AND [Imagen] = @original_Imagen AND [A] = @original_A AND [R] = @original_R AND [V] = @original_V AND [Enlace] = @original_Enlace">
<DeleteParameters>
<asp:Parameter Name="original_Cod" Type="Byte" />
<asp:Parameter Name="original_Modulo" Type="String" />
<asp:Parameter Name="original_Padre" Type="String" />
<asp:Parameter Name="original_Imagen" Type="String" />
<asp:Parameter Name="original_A" Type="Boolean" />
<asp:Parameter Name="original_R" Type="Boolean" />
<asp:Parameter Name="original_V" Type="Boolean" />
<asp:Parameter Name="original_Enlace" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Modulo" Type="String" />
<asp:Parameter Name="Padre" Type="String" />
<asp:Parameter Name="Imagen" Type="String" />
<asp:Parameter Name="A" Type="Boolean" />
<asp:Parameter Name="R" Type="Boolean" />
<asp:Parameter Name="V" Type="Boolean" />
<asp:Parameter Name="Enlace" Type="String" />
<asp:Parameter Name="original_Cod" Type="Byte" />
<asp:Parameter Name="original_Modulo" Type="String" />
<asp:Parameter Name="original_Padre" Type="String" />
<asp:Parameter Name="original_Imagen" Type="String" />
<asp:Parameter Name="original_A" Type="Boolean" />
<asp:Parameter Name="original_R" Type="Boolean" />
<asp:Parameter Name="original_V" Type="Boolean" />
<asp:Parameter Name="original_Enlace" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Modulo" Type="String" />
<asp:Parameter Name="Padre" Type="String" />
<asp:Parameter Name="Imagen" Type="String" />
<asp:Parameter Name="A" Type="Boolean" />
<asp:Parameter Name="R" Type="Boolean" />
<asp:Parameter Name="V" Type="Boolean" />
<asp:Parameter Name="Enlace" Type="String" />
</InsertParameters>
</asp:SqlDataSource>