Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if (e.Item.ItemType != ListItemType.Header)
              return;
          _objTT.GridHeading(vid, e);

          //cT.date = Convert.ToDateTime((object)DateTime.Today.Date);
          //cT.a = Convert.ToInt32((object)Hidden1.Value);
          //DataSet ds = cT.Getdate();

          if (ds.Tables[0].Rows.Count > 0)
          {
              for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
              {
                  for (int index = 1; index <= 7; ++index)
                  {
                      if (vid.Columns[index].HeaderText == ds.Tables[0].Rows[j]["Day"].ToString())
                      {
                          //e.Item.Cells[index].Text = dr["Day"].ToString() + "<Br>" + dr["Date"].ToString();
                          //vid.Columns[index].HeaderText = dr["Day"].ToString() + "<Br>" + dr["Date"].ToString();
                          e.Item.Cells[index].Text = ds.Tables[0].Rows[j]["Day"].ToString() + "<Br>" + txtentrydate.Text;
                          vid.Columns[index].HeaderText = ds.Tables[0].Rows[j]["Day"].ToString() + "<Br>" + txtentrydate.Text;
                      }


What I have tried:

At first i tried to call stored procedure they i not need the stored procedure then i commanded init so want normally call in the day of week for date in my grid heading how i write the code so kindly guide me
Posted
Updated 2-Mar-22 20:57pm

If you have a DateTime value, then the day of the week is simple:
DateTime now = DateTime.Now;
string dayOfWeek = now.DayOfWeek.ToString();
 
Share this answer
 
Comments
Member 15542635 2-Mar-22 2:36am    
where i put it
OriginalGriff 2-Mar-22 3:18am    
How the heck would I know? I have no idea what your table is supposed to look like!

Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
This should give you a hint if I have understood your issue correctly.

C#
if (vid.Columns[index].HeaderText == ds.Tables[0].Rows[j]["Day"].ToString())
{
  DateTime _tmp = dr["Day"] // assuming the object is DateTime.
  e.Item.Cells[index].Text =  _tmp.DayOfWeek.ToString() + "<Br>" + _tmp.DayOfWeek.ToString();
  //vid.Columns[index].HeaderText = dr["Day"].ToString() + "<Br>" + dr["Date"].ToString();
  e.Item.Cells[index].Text = ds.Tables[0].Rows[j]["Day"].ToString() + "<Br>" + txtentrydate.Text;
  vid.Columns[index].HeaderText = ds.Tables[0].Rows[j]["Day"].ToString() + "<Br>" + txtentrydate.Text;
}
 
Share this answer
 
 protected void vid_ItemDataBound(object sender, DataGridItemEventArgs e)
   {
       try
       {
           if (e.Item.ItemType != ListItemType.Header)
               return;
           _objTT.GridHeading(vid, e);

           string dayOfWeek = DateTime.ParseExact(txtentrydate.Text,"dd-MM-yyyy",CultureInfo.InvariantCulture).DayOfWeek.ToString();

}
       catch (Exception ex)
       {
           Log.Message(ex);
       }
   }
 
Share this answer
 

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