Well im guessing your using MS SQL, so here's what you do. Use LINQ (C will
tell you im a LINQ advocate!), import the SPROC to the designer, and the you
can call it like this:
LinqDataContext linq = new LinqDataContext();
....
private void btn_submit_Click(Object sender, EventArgs e)
{
myDetailsView.DataSource = linq.qry_search_pts();
myDetailsView.DataBind();
}
It doesn't do much in the way of increasing performance (maybe it will be a
bit faster), but it will take alot of the SqlCommands out of the .NET page,
and the data should really be in a seperate layer.
On Sun, Dec 14, 2008 at 1:19 PM, Cerebrus <[email protected]> wrote:
>
> What Brandon is trying to tell you is that you need to create an event
> handler for the Submit button which will set the DataSourceID of the
> DetailsView to your SqlDataSource. Something like this :
>
> ---
> private void btn_submit_Click(Object sender, EventArgs e)
> {
> myDetailsView.DataSourceID = "qry_search_pts";
> myDetailsView.DataBind();
> }
> ---
> Don't forget to wire up your eventhandler to the Event.
>
> On Dec 14, 8:27 pm, Adam Cary <[email protected]> wrote:
> > I don't know how to do that. I'm brand new to this. Everything I've
> done in the past was Perl CGI's or ASP 1. Please advise.
> >
> > --- On Sun, 12/14/08, Brandon Betances <[email protected]> wrote:
> >
> >
> >
> > > From: Brandon Betances <[email protected]>
> > > Subject: [DotNetDevelopment] Re: ASPX bind textbox to stored procedure
> > > To: [email protected]
> > > Date: Sunday, December 14, 2008, 7:02 AM
> > > wire up an event for the submit button that handles the
> > > procedure.
> >
> > > On Sat, Dec 13, 2008 at 2:47 PM, AC
> > > <[email protected]> wrote:
> >
> > > > Hello,
> >
> > > > I'm trying to search my database for matching
> > > patients. I have my
> > > > stored procedure that works great (attached). How can
> > > I bind a
> > > > textbox to these values? How could the results be
> > > returned to a
> > > > control (DetailView, etc.)? Help!
> >
> > > > If anyone wants to see my stored procedure, let me
> > > know. Thanks.
> >
> > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
> > > Transitional//EN" "http://
> >
> > >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > > > <%@ Page Language="C#" %>
> > > > <html dir="ltr"
> > > xmlns="http://www.w3.org/1999/xhtml">
> >
> > > > <head runat="server">
> > > > <meta http-equiv="Content-Language"
> > > content="en-us" />
> > > > <meta http-equiv="Content-Type"
> > > content="text/html; charset=utf-8" />
> > > > <title>Search Patients</title>
> > > > </head>
> >
> > > > <body>
> >
> > > > <form id="form1"
> > > runat="server">
> > > > <asp:SqlDataSource runat="server"
> > > id="qry_search_pts"
> > > > ProviderName="System.Data.SqlClient"
> > > > SelectCommandType="StoredProcedure"
> > > ConnectionString="Data
> > > > Source=TEST;Initial Catalog=TEST;Integrated
> > > Security=True"
> > > > SelectCommand="SearchResults">
> > > > <SelectParameters>
> > > > <asp:controlparameter
> > > > ControlID="frm_Chart_Number"
> > > PropertyName="Text" Name="Chart_Num"
> > > > Type="String" />
> > > > <asp:controlparameter
> > > ControlID="frm_DOB"
> > > > PropertyName="Text" Name="DOB"
> > > Type="DateTime" />
> > > > <asp:controlparameter
> > > > ControlID="frm_first_name"
> > > PropertyName="Text" Name="First_Name"
> > > > Type="String" />
> > > > <asp:controlparameter
> > > > ControlID="frm_last_name"
> > > PropertyName="Text" Name="Last_Name"
> > > > Type="String" />
> > > > </SelectParameters>
> > > > </asp:SqlDataSource>
> > > > <asp:TextBox runat="server"
> > > id="frm_Chart_Number"></
> > > > asp:TextBox>
> > > > <br />
> > > > <asp:TextBox runat="server"
> > > id="frm_DOB"></asp:TextBox>
> > > > <br />
> > > > <asp:TextBox runat="server"
> > > id="frm_first_name"></asp:TextBox>
> > > > <br />
> > > > <asp:TextBox runat="server"
> > > id="frm_last_name"></asp:TextBox>
> > > > <br />
> > > > <asp:Button runat="server"
> > > Text="Submit" id="btn_submit" />
> > > > </form>
> >
> > > > </body>
> >
> > > > </html>- Hide quoted text -
> >
> > - Show quoted text -