Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. plz hepl me to validate date on datagrid template. .....Y no one to help?

plz hepl me to validate date on datagrid template. .....Y no one to help?

Scheduled Pinned Locked Moved C#
helptutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    P_Elza
    wrote on last edited by
    #1

    hi all plz help me i am inserting date to the text box on the datagrid template.There is 2 column for that. one receive date and the other due date. due date should be greater than receive date. and the date format is dd/mm/yyyy. how to validate this. since the date format is dd.mm.yyyy, am not able to compare it with different month.plz help me to solve this. am doing this from past 4 days. but didnt end up with a solution sample code is given below

    if(((TextBox)(dgDetailData.Items[total].Cells[7].Controls[1])).Text != "")
    {
    try
    {
    DateTime txt=Convert.ToDateTime(((TextBox)(dgDetailData.Items[total].Cells[6].Controls[1])).Text);
    DateTime tst=Convert.ToDateTime(((TextBox)(dgDetailData.Items[total].Cells[7].Controls[1])).Text);
    string date=month+"/"+day+"/"+year;
    if(DateTime.Compare(txt,tst)>0)
    {
    lblmsg.Text="error";
    lbl1.Text=date.ToString();

    } 
    

    else
    {
    lbl1.Text=txt.ToString();
    InsertParam[9].Value=Production.FORMATYMONDTIME(((TextBox)(dgDetailData.Items[total].Cells[7].Controls[1])).Text);
    }
    }
    catch(Exception err)
    {
    RegisterStartupScript("startup","window.alert('1.Error:"+err.ToString()+"')");
    }
    }
    else
    {
    InsertParam[9].Value=DBNull.Value;
    }

    In this code the error occuring is if the received date is 01/10/2007 n due date id 30/09/2007, it is inserting value. if it is of same month it is working properly. ie 01/10/2007 n 10/10/2007 it accept and if it is 10/10/2007 n 01/10/2007 it is not accepting.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups