473,378 Members | 1,314 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,378 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 1044
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.