I am showing my search results in a rad grid. Rad grid is inside a panel. Whenever there are empty cells, column lines are becoming invisible.
I used the below code in prerender event of the grid, still columns lines become invisible for empty cells.
This scenario happens sometimes on grid refresh.
I used the below code in prerender event of the grid, still columns lines become invisible for empty cells.
This scenario happens sometimes on grid refresh.
protected void rgMyGrid_PreRender(object sender, EventArgs e)
{
try
{
foreach (GridDataItem item in rgMyGrid.MasterTableView.Items)
{
if (item is GridDataItem)
{
foreach (GridColumn col in rgMyGrid.Columns)
{
//Add space to the cell that has null or empty value
if (!col.ColumnType.Equals("GridTemplateColumn"))
{
if (string.IsNullOrEmpty(item[col.UniqueName].Text.Trim())
|| item[col.UniqueName].Text.Equals(" "))
{
item[col.UniqueName].Text = " ";
}
}
else
{
#region AllowSpaceInCols
switch (col.UniqueName)
{
case "lblColumn1":
Label lblColumn1= item.FindControl("lblColumn1") as Label;
if (lblColumn1.Text.Trim().Equals(String.Empty)
|| lblColumn1.Text.Trim().Equals(" "))
{
lblColumn1.Text = " ";
}
break;
case "Column2":
Label lblColumn2 = item.FindControl("lblColumn2") as Label;
if (lblColumn2 .Text.Trim().Equals(String.Empty)
|| lblColumn2 .Text.Trim().Equals(" "))
{
lblColumn2 .Text = " ";
}
break;
default:
break;
}
#endregion
}
}
}
}
}
catch (Exception ex)
{
}
}