473,385 Members | 1,856 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,385 software developers and data experts.

2.0: GridView associated to DropDownList

Hello,
Could you help me please to define GridView associated to
DropDownList.
My DropDownList "Publishers" should show publishers' names
from SQL Server table Publishers. My GridView "BooksOnDotNET"should
show books published by selected publisher. (Tables' definition
below.)
Here is part of .aspx:

<asp:DropDownList ID="Publishers" runat="server"
DataSourceID="PublishersSQL" DataTextField="Name"
DataValueField="Name">
</asp:DropDownList>
<asp:SqlDataSource ID="PublishersSQL" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLServerConnectionString %>"
SelectCommand="SELECT Name FROM Publishers ORDER BY
Name">
</asp:SqlDataSource>
<asp:GridView ID="BooksOnDotNET" runat="server"
AllowSorting="True" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="BooksSQL"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775"
/>
</asp:GridView>
<asp:SqlDataSource ID="BooksSQL" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLServerConnectionString %>"
SelectCommand="SELECT Books.Tytuł, Books.Autor,
Books.ISBN FROM Booksi INNER JOIN Publications ON Booksi.ISBN =
Publications.ISBN WHERE (Publications.PublisherName = @Publisher)
ORDER BY
Books.Title" >
<SelectParameters>
<asp:ControlParameter ControlID="Publishers"
Name="Publisher" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

Here you have definitions of Publishers, Books, Publications (SQL
Server 2005):

CREATE TABLE [dbo].[Publishers](
[Name] [varchar](50) NOT NULL,
[Address] [varchar](75) NULL,
[WWWPage] [varchar](50) NULL,
[email] [varchar](50) NULL,
[Phone] [varchar](15) COLLATE NULL,
CONSTRAINT [PK_Publishers] PRIMARY KEY CLUSTERED
(
[Name] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[Books](
[ISBN] [nchar](13) NOT NULL,
[Title] [varchar](50) NOT NULL,
[Autor] [varchar](50) NULL,
[OriginalTitle] [varchar](50) NULL,
[PublicationsNumber] [smallint] NULL,
CONSTRAINT [PK_Books] PRIMARY KEY CLUSTERED
(
[ISBN] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[Publications](
[ISBN] [nchar](13) NOT NULL,
[PublicationName] [varchar](50) NOT
NULL,
[Number] [varchar](10) NOT NULL,
[City] [varchar](30) NULL,
[Year] [smallint] NULL,
[Translation] [varchar](50) NULL,
CONSTRAINT [PK_Publications] PRIMARY KEY CLUSTERED
(
[ISBN] ASC,
[PublisherName] ASC,
[Number] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Here is part of Web.Config:

<connectionStrings>
<add
name="SQLServerConnectionString"
connectionString="Data Source=PC\SQLEXPRESS;Initial
Catalog=DemoDotNET;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>

There's sotmething wrong because GridView is not displayed (I had it
visible for the moment but data displayed was incorrect.)
Please help to define asp: controls.

Thank you very much!
/RAM/
May 30 '06 #1
0 1282

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

Similar topics

3
by: mateo | last post by:
Hello, I have a GridView inside which i want to show 3 dropdownList (one for each Column). So i've created 3 TemplateField Continent Country City
1
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. ...
1
by: R.A.M. | last post by:
Hello, Could you help me please to define GridView associated to DropDownList... My DropDownList "Publishers" should show publishers' names from SQL Server table Publishers. My GridView...
0
by: Managed Code | last post by:
Hello, I have a status and definition table. The status table's current status field relates the ID field of the definition table. I am trying to retrieve the definitions that are associated...
0
by: R.A.M. | last post by:
Hi, Please help. I have definied a GridView associated to DropDownList but it's not visible. Here's the code: <asp:DropDownList ID="Publishers" runat="server" DataSourceID="PublishersSQL"...
0
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an...
5
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
0
parshupooja
by: parshupooja | last post by:
Hi all, I need help. I am using asp.net C# . I have binded gridview with 5 columns. I have Dropdownlist in 4 columns Morning in, morning out, afternoon in and afternoon out and label in 5 column...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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?
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...
0
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...
0
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,...
0
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...

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.