i have an ajax Calender extender along with textbox in gridview, it works fine, when i select some date from calendar then it tranfers date to textbox and after clicking Update button in gridview , it sends date to database , Fine
but when i don't select any thing from calender i.e. when textbox remains empty , and when i click update button , then it sends 1900-01-01,
why ? please someone help ......
here is my code , even i treid if else conditions but else never gets executed ,
code:
protected void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
//Label lblMsgEmail = new Label();
GridView gvr = GridView1;
//GridViewRow r = GridView1.Rows;
int index = Convert.ToInt32(e.CommandArgument);
int pk = Convert.ToInt32(GridView1.DataKeys[index].Value);
TextBox txtb = (TextBox) (gvr.Rows[index].FindControl("txtCal"));
// TextBox txtb1 = (TextBox)(gvr.Rows[index].FindControl("txtCal2"));
AjaxControlToolkit.CalendarExtender txtBox = (AjaxControlToolkit.CalendarExtender)(gvr.Rows[index].FindControl("CalendarExtender1"));
Response.Write(txtb.Text);
txtb.Text = txtBox.SelectedDate.ToString();
String date = Request.Form[txtb.UniqueID];
Response.Write(date);
if(date != null || date!="")
{
SqlDataSource1.UpdateCommand = "UPDATE [tblScruitnyTeam] SET [interview] = '"+ date +"', [name] = @name, [designation] = @designation, [commiteerole] = @commiteerole, [signature] = @signature, [userid] = @userid WHERE [teamid] ='"+pk+"'";
}
else
{
SqlDataSource1.UpdateCommand = "UPDATE [tblScruitnyTeam] SET [interview] = '" + "Null" + "', [name] = @name, [designation] = @designation, [commiteerole] = @commiteerole, [signature] = @signature, [userid] = @userid WHERE [teamid] ='" + pk + "'";
Response.Write("Else");
}