how to use parameters in code behind to access some controls in my aspx file using C#

speergonporgo

New Member
i have 2 textbox that has a date values in my aspx file. I would like to access these 2 controls in my select statement using code behind but i am getting error like this:'Must declare the scalar variable "@txtStartClosingDate"so what am i missing here in my code behind here? thanks\[code\] protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MainGridView.DataSource = GetData("select GroupCategory, Count(Status1) as TotalCount from [MasterProject] where Closing_Date >= @txtStartClosingDate and Closing_Date <= @txtEndClosingDate and Status1 is not null group by GroupCategory"); MainGridView.DataBind(); } }\[/code\]Here is one of the textbox that i am trying to reference:\[code\]<asp:TextBox ID="txtStartClosingDate" runat="server" CssClass="datepicker"></asp:TextBox>\[/code\]
 
Back
Top