Click here to Skip to main content
15,898,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I want to read dataTable for previous records,

means, if the records are already their for Today's date, then it should throw an alert.

n i have datatable where these records are inserted,

now i want to compare those records with the textbox of DatePicker.

Plzzz Suggest...

Thanks
Posted
Comments
ZurdoDev 15-Feb-14 14:24pm    
Where are you stuck?

C#
foreach(DataRow dr in dt.Rows) // dt => your datatable
{
    if(dr["Name"].ToString() == nameTxt.Text)
    {
        // do something here...
        // same check for your date thing...
    }
}


Hope this will help you,Good Luck :)

-KR
 
Share this answer
 
protected void txtvDate_TextChanged1(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt = DAL.GenericSP_RS(1, "Sp_GetVehicleTrack", "");
            foreach (DataRow row in dt.Rows)
            {
                foreach (var item in row.ItemArray)
                {
                    DateTime dtc = Convert.ToDateTime(txtvDate.Text);
                    DateTime idt = Convert.ToDateTime(item);
                    if (dtc == idt)
                    {
                        Response.Redirect("VehicleManagement.aspx?idt=" + txtvDate.Text);
                       //lblmsg.Text =  "Record already inserted!";
                    }
                }
            }
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900