Hi
I have below code in Gridview RowDataBound. I want to set font-size
TableCell cell = new TableCell();
TextBox txtColumn = new TextBox();
txtColumn.ID = "txtSessionDate";
txtColumn.CssClass = "form-control daterange-single";
cell.Controls.Add(txtColumn);
e.Row.Cells.Add(cell);
Thanks
Tuhin PaulPosted May 21, 2023, 2:43 PM
See below my observations:
1. Use the var keyword to simplify the code and improve readability:
2. Use a more descriptive variable name instead of `txtColumn`, such as `textBox`.
3. Consider moving the CSS class assignment outside the RowDataBound event handler if it is a static value for all TextBox controls in the GridView. This way, it will not be set repeatedly for each row during the event.
Tuhin PaulPosted May 21, 2023, 2:21 PM
You can set the font size of the text box in the RowDataBound event by using the following code:
Mohamed Azarudeen ZPosted May 21, 2023, 12:05 PM
Hi Ramco to do that kindly modify your code as below