R
R.A.M.
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:
<aspropDownList ID="Publishers" runat="server"
DataSourceID="PublishersSQL" DataTextField="Name"
DataValueField="Name">
</aspropDownList>
<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,
[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>
PROBLEM: 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/
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:
<aspropDownList ID="Publishers" runat="server"
DataSourceID="PublishersSQL" DataTextField="Name"
DataValueField="Name">
</aspropDownList>
<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,
[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>
PROBLEM: 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/