473,287 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:CodeTrackerConnectionString %>"
SelectCommand="SELECT [PageID], [Title], [Description], [Keywords], [url]
FROM [tblPages]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
ConnectionStrings:CodeTrackerConnectionString %>"
SelectCommand="SELECT [Title], [Description], [Keywords], [url], [PageID]
FROM [tblPages] WHERE ([PageID] = @PageID)"

<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="PageID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
May 15 '06 #1
1 1041
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****@btinternet.com> wrote in message
news:OB****************@TK2MSFTNGP04.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:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CodeTrackerConnectionString %>"
SelectCommand="SELECT [PageID], [Title], [Description], [Keywords], [url]
FROM [tblPages]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:CodeTrackerConnectionString %>"
SelectCommand="SELECT [Title], [Description], [Keywords], [url], [PageID]
FROM [tblPages] WHERE ([PageID] = @PageID)"

<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="PageID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

May 15 '06 #2

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

Similar topics

5
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"...
5
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...
8
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...
4
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.