473,666 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp.net 2.0, Gridview + Detailview

1 New Member
Hi
I have Gridview and DetailView both on one page.
I am showing the list in the Gridview and the particular record in DetailView.
the problem is When i EDIT on the DetailView and try to UPDATE it. It doesn't work.
I have setup 2 sqlDatasource for each Control. the Select Query for SqlDatasource which is bound to the DetailView has the control parameter which is bound to Griview.Selecte dValue Parameter.

here's my markup for the page.

<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue" AllowSorting="T rue"
AutoGenerateCol umns="False" DataSourceID="S qlDataSource1">
<PagerSetting s FirstPageText=" First" LastPageText="L ast" Mode="NextPrevi ousFirstLast"
NextPageText="N ext" PreviousPageTex t="Prev" />
<Columns>
<asp:CommandFie ld ShowSelectButto n="True" />
<asp:BoundFie ld DataField="depn ame" HeaderText="Dep artment" SortExpression= "depname" />
</Columns>
</asp:GridView>
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConflictDetecti on="CompareAllV alues"
ConnectionStrin g="<%$ ConnectionStrin gs:LaborTrakCon nectionString %>" DeleteCommand=" DELETE FROM [tblAdministrati on] WHERE [depID] = @original_depID AND [depname] = @original_depna me"
InsertCommand=" INSERT INTO [tblAdministrati on] ([depname]) VALUES (@depname)"
OldValuesParame terFormatString ="original_{ 0}" SelectCommand=" SELECT * FROM [tblAdministrati on]"
UpdateCommand=" UPDATE [tblAdministrati on] SET [depname] = @depname WHERE [depID] = @original_depID AND [depname] = @original_depna me">
<DeleteParamete rs>
<asp:Paramete r Name="original_ depID" Type="Int64" />
<asp:Paramete r Name="original_ depname" Type="String" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="depname" Type="String" />
<asp:Paramete r Name="original_ depID" Type="Int64" />
<asp:Paramete r Name="original_ depname" Type="String" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="depname" Type="String" />
</InsertParameter s>
</asp:SqlDataSour ce>
</td>
<td style="width: 3px; height: 20px">
&nbsp;<asp:Deta ilsView ID="DetailsView 1" runat="server" AutoGenerateRow s="False"
DataKeyNames="d epID" DataSourceID="S qlDataSource2" Height="50px" Width="125px">
<Fields>
<asp:BoundFie ld DataField="depI D" HeaderText="dep ID" InsertVisible=" False" ReadOnly="True"
SortExpression= "depID" />
<asp:BoundFie ld DataField="rcID " HeaderText="rcI D" SortExpression= "rcID" />
<asp:BoundFie ld DataField="dept name" HeaderText="dep tname" SortExpression= "deptname" />
<asp:CommandFie ld ShowEditButton= "True" ShowInsertButto n="True" />
</Fields>
</asp:DetailsView >
<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server" ConflictDetecti on="CompareAllV alues"
ConnectionStrin g="<%$ ConnectionStrin gs:LaborTrakCon nectionString %>" DeleteCommand=" DELETE FROM [tblDepartments] WHERE [depID] = @original_depID AND [rcID] = @original_rcID AND [deptname] = @original_deptn ame"
InsertCommand=" INSERT INTO [tblDepartments] ([rcID], [deptname]) VALUES (@rcID, @deptname)"
OldValuesParame terFormatString ="original_{ 0}" SelectCommand=" SELECT [depID], [rcID], [deptname] FROM [tblDepartments] WHERE ([depID] = @depID)"
UpdateCommand=" UPDATE [tblDepartments] SET [rcID] = @rcID, [deptname] = @deptname WHERE [depID] = @original_depID AND [rcID] = @original_rcID AND [deptname] = @original_deptn ame">
<DeleteParamete rs>
<asp:Paramete r Name="original_ depID" Type="Int64" />
<asp:Paramete r Name="original_ rcID" Type="String" />
<asp:Paramete r Name="original_ deptname" Type="String" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="rcID" Type="String" />
<asp:Paramete r Name="deptname" Type="String" />
<asp:Paramete r Name="original_ depID" Type="Int64" />
<asp:Paramete r Name="original_ rcID" Type="String" />
<asp:Paramete r Name="original_ deptname" Type="String" />
</UpdateParameter s>
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Grid View1" Name="depID" PropertyName="S electedValue"
Type="Int64" />
</SelectParameter s>
<InsertParamete rs>
<asp:Paramete r Name="rcID" Type="String" />
<asp:Paramete r Name="deptname" Type="String" />
</InsertParameter s>
</asp:SqlDataSour ce>


I don't know what's wrong.
When i try checking in with the ItemUpdating event of SqlDataSource for the DetailView the e.NewValues.Cou nt shows 2. but
e.NewValues.Ite m(1).ToString says it's "Nothing"!!

i don't know what's going wrong.

pls help

thanks
Deepak Palkar
Apr 4 '07 #1
0 3142

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1082
by: Kha Tran | last post by:
Please give me a sample of using xpo objectdatasource gridview detailview for select,insert,update and delete Thanks -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
26
1911
by: onearth | last post by:
Hello I already managed to add a dynamic DetailView under a row of Gridview if a user presses the row with the mouse... Is it possible to add under it a table(or even better load a simple HTML file that contains the tables).. not a detailview like I already did..Because i would like to be able to design the table as i wish and not to be limited to the DetailView Design which only contains rows & coluwns.
0
951
by: byron | last post by:
hello, i would like to use de gridview to show the list of records and use the autoselect to populate the detailview to update and delete. i tried everything but nothing works. help needed.
4
12891
by: Dabbler | last post by:
Is there a way to let the user select a gridview row by clicking anywhere in the row (e.g. on any column)? The gridview would be readonly and I would like to bring up a detailview of the row the user clicked on. Thanks.
0
1204
by: Roald van Geleuken | last post by:
Been trying a few things but not been able to solve this so far. I have 3 tables: - source data shown in a paged gridview - processed data (1 or more records per source record) shown in paged detailview - additonal messages ( 1 or more per processed data record) shown in another non-paged gridview Selecting a source record will show the relevant processed data and additional messages. Linking the 3 views was a pain in itself, but I got
1
1884
by: kashif456 | last post by:
I can't figure out why I am getting error updating, deleting and inserting new rows. I am amble to get my dataview populated and also detailview populated: Here's my code: <%@ Page Language=VB CompilationMode=Auto Inherits=CrisisResponseBase %> <script runat="server"> 'Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
0
1240
by: Luqman | last post by:
I have used a single objectDataSource for GridView and DetailView, and when I load the page, the GridView shows all the entries of Invoice, and DetailView shows the 1st entry of Invoice, thats all ok. Now what I want is to click on Select Button of DetailView and that row should appear in DetailView, using the same ObjectDataSource, any idea ? I tried using : DetailView1.SelectedValue=GridView1.SelectedDataKey.Value
0
1040
by: =?Utf-8?B?RWQgV2FycmVu?= | last post by:
After working on this for the past three days!! 1. I build a simple table in sql server 2005 TestID (int, auto increment) (key) TestText (nvchar,10) 2. In visual studio 2005, I build a simple dataset, using one tableadapter based on the test table, select both fields, and use the wizard to build the get, update,insert, delete queries.
7
2687
by: Joe Kovac | last post by:
Hi! I have one page with a GridView. Their I can select one item and edit this item on an own page within a DetailsView. After updating the entry I want the user to be able to get back to the same position of the GridView as before. E.g.: The user selected an item on the 3rd of 5 GridView pages. He edits the item and now he shall come back to the updated page 3. How do I achieve this the easies way?
0
8449
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8360
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8876
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8784
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.