using stored procedure with parameter

Sep 4, 2007
Reaction score

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 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" "">
<html xmlns="" >

<head runat="server">

<title>Untitled Page</title>


<form id="form1" runat="server">


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"

SelectCommand="ViewSelectedRecord" SelectCommandType="StoredProcedure">

<selectParameters >

<asp:ControlParameter Name ="City" ControlID ="TextBox1" Type=String PropertyName= "text"/>



<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" />


<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" />


<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" />







Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question