Hi everyone i am using gridview to display data in which i have used date in header like 01,02,03,04,05 upto end of month and tooltip also used to display data description whenever user move mouse over it, but at end when i see it display date in header in format yyyy-mm-dd but i want only date no month or year
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 1; i <= e.Row.Cells.Count - 1; i++)
{
if (e.Row.Cells[i].Text == "0" || string.IsNullOrEmpty(e.Row.Cells[i].Text) || e.Row.Cells[i].Text == " ")
{
e.Row.Cells[i].Text = "";
}
else
{
e.Row.Cells[i].BackColor = System.Drawing.Color.DarkOrange;
dateSetExport.Tables.Clear();
dateSetExport.Reset();
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@Employe_Id", e.Row.Cells[0].Text.Split('-')[0]);
param[1] = new SqlParameter("@Startdate", gvDetails.HeaderRow.Cells[i].Text);
DataTable dt1 = DataHelper.getDataTableExecuteSP("usp_GetToolTip", param);
dt1.TableName = "ToolTip";
dateSetExport.Tables.Add(dt1);
string tooltip = "";
for (int j = 0; j < dt1.Rows.Count; j++)
{
tooltip = tooltip + dt1.Rows[j]["normal_working_hours"].ToString() + " Hours : " + dt1.Rows[j]["description"].ToString() + "\n\n";
}
e.Row.Cells[i].ToolTip = tooltip;
}
}
}
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left;
if (e.Row.RowIndex == 1)
{
GridView objGridView = (GridView)sender;
GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableHeaderCell objtablecell = new TableHeaderCell();
foreach (TableCell tblCell in e.Row.Cells)
{
objtablecell = new TableHeaderCell();
objgridviewrow.Cells.Add(objtablecell);
}
objgridviewrow.ID = "NewHeader";
objgridviewrow.BackColor = System.Drawing.Color.FromArgb(0xf0, 0x9b, 0x16);
objgridviewrow.ForeColor = System.Drawing.Color.Black;
objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);
GridViewRow firstRow = (GridViewRow)gvDetails.FindControl("NewHeader");
GridViewRow secondRow = gvDetails.HeaderRow;
for (int i = secondRow.Cells.Count - 2; i >= 0; i--)
{
if (secondRow.Cells[i].Text.Substring(5,2) == secondRow.Cells[i + 1].Text.Substring(5,2))
{
firstRow.Cells[i].ColumnSpan = firstRow.Cells[i+1].ColumnSpan < 2 ? 2 : firstRow.Cells[i+1].ColumnSpan + 1;
firstRow.Cells[i + 1].Visible = false;
firstRow.Cells[i].Text = CellText(secondRow.Cells[i].Text.Substring(5, 2)) + " " + secondRow.Cells[i].Text.Substring(0, 4);
firstRow.Cells[i].HorizontalAlign = HorizontalAlign.Center;
}
if (i== 1 && (firstRow.Cells[1].Text==""))
{
firstRow.Cells[1].Text = CellText(secondRow.Cells[1].Text.Substring(5, 2)) + " " + secondRow.Cells[1].Text.Substring(0, 4);
firstRow.Cells[1].HorizontalAlign = HorizontalAlign.Center;
}
else if (i == 0 && (firstRow.Cells[firstRow.Cells.Count - 1].Text == ""))
{
string fullText = CellText(secondRow.Cells[secondRow.Cells.Count - 1].Text.Substring(5, 2)) + " " + secondRow.Cells[secondRow.Cells.Count - 1].Text.Substring(0, 4);
firstRow.Cells[firstRow.Cells.Count - 1].Text = fullText;
firstRow.Cells[firstRow.Cells.Count - 1].HorizontalAlign = HorizontalAlign.Center;
}
}
}
}
This is my grid
<asp:GridView ID="gvDetails" runat="server" Style="font-size: 13px; width: 100%;" CssClass="grid clsWrap" AutoGenerateColumns="True" OnRowDataBound="gvDetails_RowDataBound">
<HeaderStyle Font-Bold="False" CssClass="Font gvheaderstyle" Wrap="False"/>
<PagerStyle CssClass="gridB" ForeColor="WhiteSmoke" />
<RowStyle HorizontalAlign="Center" />
</asp:GridView>
What I have tried:
this for each converts date in the format i want but if i uncomment this foreach it effect tooltip in each row that result in reading data of one row if i comment it effect date in header of gridview results in yyyy-mm-dd but i want only day
help me