Texpert 0 Newbie Poster

Hi,

I am having problem with my Editable GridView. I am selecting columns from SQL-Server 2005 DB using a store procedure [with multiple tables in it] and then I wrote UPDATE and DELTE statements in the GridView query builder.

When I run the page, Select and delete works fine but while updating the row in database , it inserts all the NULLS for those columns whose values are not changed in the Grid.

Please see the attached code for review
============================================

<asp:GridView ID="GridView2" runat="server" AllowSorting="True" AutoGenerateColumns="False"
        DataKeyNames="RegID" DataSourceID="SqlDataSource2" Style="z-index: 102; left: 453px;
        position: absolute; top: 305px">
        <Columns>
            <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/icon-pencil-x.gif"
                DeleteImageUrl="~/Images/icon-delete.gif" EditImageUrl="~/Images/icon-pencil.gif"
                ShowDeleteButton="True" ShowEditButton="True" UpdateImageUrl="~/Images/icon-floppy.gif" />
            <asp:BoundField DataField="RegID" HeaderText="RegID" InsertVisible="True" ReadOnly="True"
                SortExpression="RegID" Visible="False" />
            <asp:BoundField DataField="STU_ID" HeaderText="STU_ID" SortExpression="STU_ID" Visible="False" />
            <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="Name" />
            <asp:BoundField DataField="Branch_ID" HeaderText="Branch_ID" SortExpression="Branch_ID"
                Visible="False" />
            <asp:BoundField DataField="Branch_Name" HeaderText="Branch_Name" SortExpression="Branch_Name" />
            <asp:BoundField DataField="AcademicYear_ID" HeaderText="AcademicYear_ID" SortExpression="AcademicYear_ID"
                Visible="False" />
            <asp:BoundField DataField="Academic_Year" HeaderText="Academic_Year" SortExpression="Academic_Year" />
            <asp:BoundField DataField="Registration_Type" HeaderText="Registration_Type" SortExpression="Registration_Type" />
            <asp:BoundField DataField="regdate" HeaderText="regdate" ReadOnly="True" SortExpression="regdate" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:KPLCOneSourceConnectionString %>"
        OldValuesParameterFormatString="original_{0}" DeleteCommand="DELETE FROM Registration WHERE (RegID = @Original_RegID)"
        SelectCommand="GetRegDetails" SelectCommandType="StoredProcedure" UpdateCommand="UPDATE Registration SET Branch_ID = @Branch_ID, AcademicYear_ID = @AcademicYear_ID, Registration_Type = @Registration_Type, Registartion_Date = @Registration_Date WHERE (RegID = @original_RegID)">
        <DeleteParameters>
            <asp:Parameter Name="Original_RegID" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Branch_ID" />
            <asp:Parameter Name="AcademicYear_ID" />
            <asp:Parameter Name="Registration_Type" />
            <asp:Parameter Name="Registration_Date" />
            <asp:Parameter Name="original_RegID" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="vStudent_ID" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

==================================
select statement in Store Proc is

SELECT RegID,
Registration.Student_ID as STU_ID,
Last_Name + ' ' + First_Name as Name,
Registration.Branch_ID,
Branch_Name,Registration.AcademicYear_ID,
Academic_Year,
Registration_Type,
ISNULL(CONVERT(nvarchar(11),Registartion_Date , 109),' / / ') as regdate,
Registration.UpdatedBy,
ISNULL(CONVERT(nvarchar(11),Registration.UpdatedDate , 109),' / / ') as EnterDate
from Registration
INNER JOIN Student on Registration.Student_ID = student.Student_ID
INNER JOIN Branch on Registration.Branch_ID = Branch.Branch_ID
INNER JOIN Academic_Year on Registration.AcademicYear_ID = Academic_Year.Academic_YearID
Where Registration.Student_ID = @vStudent_ID
ORDER BY regdate