•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,499 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,456 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 6683 | Replies: 0
![]() |
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
============================================
==================================
select statement in Store Proc is
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Update row using Excelsheet (C#)
- C# .NET Gridview (C#)
- Getting values from GridView Controls (ASP.NET)
- Javascript Problem.... (JavaScript / DHTML / AJAX)
- Controls in GridView (ASP.NET)
- Re: Problem in updating project for Microsoft Project 2002 and 2003 (Windows Software)
- Having problems with adding a row to a DataSet (VB.NET)
- GridView hiding cells dynamically (ASP.NET)
- updating 2 HTML tables on one PHP page (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: neeeeeeed help
- Next Thread: How to Set web page resolution in asp.net


Linear Mode