- Joined
- Sep 4, 2007
- Messages
- 3
- Reaction score
- 0
Hi
i am trying to call a stored procedure that contain one parameter (CIty). But for some reason it doesn't display any records ..(i tried the same query in SQL Server Management studio and got the decired record ...so i must be doing something wrong... On the page i have created a textbox and actually thatswhere user enter the city name: the code is given bellow:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CheckingStoreProcedure.aspx.vb" Inherits="GridView_Checking.CheckingStoreProcedure" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="ViewSelectedRecord" SelectCommandType="StoredProcedure">
<selectParameters >
<asp:ControlParameter Name ="City" ControlID ="TextBox1" Type=String PropertyName= "text"/>
</selectParameters>
</asp:SqlDataSource>
<asp:TextBox ID="TextBox1" runat="server" Style="left: 11px; position: relative;
top: -2px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Style="left: 60px; position: relative; top: -1px"
Text="Button" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="StudentID" DataMember="DefaultView" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None" Style="position: relative">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="StudentID" HeaderText="StudentID" ReadOnly="True" SortExpression="StudentID" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Course" HeaderText="Course" SortExpression="Course" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="YearOfGraduation" HeaderText="YearOfGraduation" SortExpression="YearOfGraduation" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
</Columns>
<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>
</div>
</form>
</body>
</html>
Cheers
Sheraz
i am trying to call a stored procedure that contain one parameter (CIty). But for some reason it doesn't display any records ..(i tried the same query in SQL Server Management studio and got the decired record ...so i must be doing something wrong... On the page i have created a textbox and actually thatswhere user enter the city name: the code is given bellow:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CheckingStoreProcedure.aspx.vb" Inherits="GridView_Checking.CheckingStoreProcedure" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="ViewSelectedRecord" SelectCommandType="StoredProcedure">
<selectParameters >
<asp:ControlParameter Name ="City" ControlID ="TextBox1" Type=String PropertyName= "text"/>
</selectParameters>
</asp:SqlDataSource>
<asp:TextBox ID="TextBox1" runat="server" Style="left: 11px; position: relative;
top: -2px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Style="left: 60px; position: relative; top: -1px"
Text="Button" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="StudentID" DataMember="DefaultView" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None" Style="position: relative">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="StudentID" HeaderText="StudentID" ReadOnly="True" SortExpression="StudentID" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Course" HeaderText="Course" SortExpression="Course" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="YearOfGraduation" HeaderText="YearOfGraduation" SortExpression="YearOfGraduation" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
</Columns>
<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>
</div>
</form>
</body>
</html>
Cheers
Sheraz