Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a row in a gridview

Status
Not open for further replies.

auchtum

Programmer
Nov 21, 2008
20
US
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:
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>
 
You are using datasource controls, I suggest you don't they cause problems with debugging as in this case. You should see the error somewhere, with a line number. check your application event logs also to determine the error.
 
Ok, I'll do it and let you know about my findings
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top