| | |
Problem Updating Row in GridView
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
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.NET Syntax (Toggle Plain Text)
<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
ASP.NET Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal forms formview gridview gudi homeedition iis javascript jquery listbox menu microsoft mouse mssql nameisnotdeclared news opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers





