473,698 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding sqldatacontrol to gridview

I have two SQLDataControls on a page. The first pulls all the data from a
table and is then bound to a gridview. The second uses the selected value in
the gridview which is in turn bound to a formview. When I run the page no
binding takes place, I assume that's because I haven't selected the
gridview. When I select a link it does nothing. What am I doing wrong?

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:CodeTrackerC onnectionString %>"
SelectCommand=" SELECT [PageID], [Title], [Description], [Keywords], [url]
FROM [tblPages]">
</asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:CodeTrackerC onnectionString %>"
SelectCommand=" SELECT [Title], [Description], [Keywords], [url], [PageID]
FROM [tblPages] WHERE ([PageID] = @PageID)"

<SelectParamete rs>
<asp:ControlPar ameter ControlID="Grid View1" Name="PageID"
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>
May 15 '06 #1
1 1056
Make sure you have in your Gridview1 declaration:

datakeynames=[PageID]

This should happen automatically if your primary key of table tblPages is
set to PageID.

"Chris" <no****@btinter net.com> wrote in message
news:OB******** ********@TK2MSF TNGP04.phx.gbl. ..
I have two SQLDataControls on a page. The first pulls all the data from a
table and is then bound to a gridview. The second uses the selected value
in the gridview which is in turn bound to a formview. When I run the page
no binding takes place, I assume that's because I haven't selected the
gridview. When I select a link it does nothing. What am I doing wrong?

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CodeTrackerC onnectionString %>"
SelectCommand=" SELECT [PageID], [Title], [Description], [Keywords], [url]
FROM [tblPages]">
</asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CodeTrackerC onnectionString %>"
SelectCommand=" SELECT [Title], [Description], [Keywords], [url], [PageID]
FROM [tblPages] WHERE ([PageID] = @PageID)"

<SelectParamete rs>
<asp:ControlPar ameter ControlID="Grid View1" Name="PageID"
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>

May 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
18537
by: sck10 | last post by:
Hello, I have a GridView that is using the following to connect to a SQL Server 2000 stored procedure: <asp:SqlDataSource ID="dsWebDocList" SelectCommand="sp_web_WebDocument" ConnectionString="<%$ ConnectionStrings:cnnSQL_Connect %>" Runat="server"> <SelectParameters> <asp:Parameter Type="String" DefaultValue="FindWebDocAll"
5
11217
by: Amit | last post by:
Hello, I have a simple search screen, with two drop-downs and a text box. There's also a GridView control that is using a SqlDataSource control to show the matching results. The SqlDataSource uses the control values in its query as parameters. Two questions: 1. When the Find button is clicked, how do I tell the GridView to load the data? 2. How do I stop the GridView from data binding when the page first loads? I don't want to...
8
8529
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The gridview's databind method is apparently called when the page is loaded as I have no code calling the databind method. How can I keep the gridview from databinding automatically and control it myself?
4
2604
by: Mike | last post by:
I'm having trouble getting a gridview to bind. I probably missing something completely obvious and would appreciate any help on offer. I'm passing parameters via querystring, and have created a stored proc as follows: qGetSearchResults: SELECT Adverts.AdvertID,
0
9157
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
9027
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
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.