Hi
I have below code in Gridview RowDataBound. I want to give header also the name like Date.
TableCell cell = new TableCell();
TextBox txtColumn = new TextBox();
txtColumn.ID = "txtSessionDate";
txtColumn.CssClass = "form-control daterange-single";
txtColumn.Font.Size = new FontUnit("10px");
cell.Controls.Add(txtColumn);
e.Row.Cells.Add(cell);
Thanks
Ramco RamcoPosted Jun 9, 2023, 6:14 AM
Hi All
When i write Header part it shows columns like below . Secondly i want this column to be non-sortable
Image attached . In the end see column is going outside
Thanks
Amit MohantyPosted Jun 9, 2023, 5:20 AM
Deepak RawatPosted Jun 9, 2023, 5:13 AM
To add a header to the
TableCellin theGridView'sRowDataBoundevent, you can create a newTableCellfor the header, set its text, and add it to theGridView's header row. Here's an updated version of your code:In this code, I've added a condition to check if the current row is the header row (
DataControlRowType.Header). If it is, a newTableCellis created, and the desired header text is set using theTextproperty. Finally, the header cell is added to theGridView's header row (e.Row.Cells.Add(headerCell)).Make sure to replace
GridView1with the ID of your actualGridViewcontrol in your code.