Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 917
  • Last Modified:

How to set a default value in a text box

I have a gridview that looks to a textbox for the parameter to pass to my stored procedure in SQL.  I would like to have the textbox default when the page loads to yesterdays date so the gridview will run with yesterdays date as the parameter, but I also need to be able to re-run the stored procedure when the user changes the date in the textbox.  I don't know how to set the textbox to default to yesterdays date except for using the pageload event which obviously means I can only use yesterdays date because whatever date is typed in is just reset when the page reloads.  Can someone please help me with this?  I know very little about asp.net and visual studios.  
0
goffer
Asked:
goffer
1 Solution
 
CB_ThirumalaiCommented:
ok, here is an example
<!-- in the aspx page -->
<asp:TextBox ID="textbox1" runat="server" EnableViewState="true" />
// in the page load
If Not IsPostBack Then
   textbox1.Text = CStr(Format(Date.Now.AddDays(-1), "MM/dd/yyyy"))
End If
// If the user changes the date, it will hold the new date

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now