Hi all,
plz help, i want to pass the date value code page to select stored procedure for bind gridview. select stored procedure taking date value in mm/dd/yyyy format for e.g. @date= 05/13 like..
and i wnt to pass value from code page using textbox. the textbox date format is dd/mm/yyyy. for e.g. textbox.Text=13/05 like..
thanks in advance....
Loading
Raju KatarePosted Apr 3, 2012, 3:18 AM
Convert.ToDateTime(DateTime.ParseExact(txtFromDate.Text, "dd/MM/yyyy", null))
txtFromDate:
txtToDate:
btnSubmit:
========================================================================================================================
In Page_Load:
if (!IsPostBack)
{
txtFromDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
txtToDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
txtFromDate.Text = txtToDate.Text = "";
}
btnSubmit_Click:
foreach
(
string item in
GetDateRange
(
Convert.ToDateTime(DateTime.ParseExact(txtFromDate.Text, "dd/MM/yyyy", null)),
Convert.ToDateTime(DateTime.ParseExact(txtToDate.Text, "dd/MM/yyyy", null))
)
)
{
Response.Write(item);
}
GetDateRange:
public List
{
if (StartingDate > EndingDate)
{ return null; }
List
DateTime tmpDate = StartingDate;
do { rv.Add(tmpDate.ToShortDateString()); tmpDate = tmpDate.AddDays(1); }
while (tmpDate <= EndingDate);
return rv;
}
========================================================================================================================