Hi, can anyone help to correct the below codes, below are the DropDownList, SQL dataSource and GridView. What I want was when selected the item in the dropDownList, the gridView will displays the selected data. But somehow, some error occurred and can't display the data. Can anyonehHelp?
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script runat="server">
Sub Get_Book_Type (Src As Object, Args As EventArgs)
Dim SQLString As String
SQLString = "SELECT BookID, BookTitle, BookPrice, BookQty FROM Books " & _
"WHERE BookType = '" & TypeList.SelectedValue & "' " & _
"ORDER BY BookID"
BookSource2.SelectCommand = SQLString
End Sub
</SCRIPT>
</head>
<body>
<form id="Form1" Runat="Server">
<h3>View Book Types</h3>
<asp:SqlDataSource ID="BookSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:wongConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:wongConnectionString1.ProviderName %>"
SelectCommand="SELECT [BookID], [BookTitle], [BookPrice], [BookQty], [BookType] FROM [Books]">
</asp:SqlDataSource>
<asp:DropDownList id="TypeList" Runat="Server"
DataSourceID="BookSource1"
DataTextField="BookType"
DataValueField="BookType"
AutoPostBack="True"
OnSelectedIndexChanged="Get_Book_Type"/><br/><br/>
<asp:SqlDataSource ID="BookSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:wongConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:wongConnectionString1.ProviderName %>"
SelectCommand="SELECT [BookID], [BookTitle], [BookPrice], [BookQty]FROM [Books]WHERE [BookType]=@BookType">
</asp:SqlDataSource>
<asp:GridView id="BookGrid" DataSourceID="BookSource2" Runat="Server"/>
<br />
</form>
</body>
</html>