Number Allignment in gridview for dynamic data display
protected void dgBatting1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataTable dt=(DataTable)((GridView)sender).DataSource;
if (e.Row.RowType == DataControlRowType.DataRow)
{
for(int i=0; i < e.Row.Cells.Count; i++)
{
if (dt.Columns[i].DataType == typeof(System.Int32) || dt.Columns[i].DataType == typeof(System.Decimal))
{
e.Row.Cells[i].HorizontalAlign = HorizontalAlign.Right;
}
}
}
}
{
DataTable dt=(DataTable)((GridView)sender).DataSource;
if (e.Row.RowType == DataControlRowType.DataRow)
{
for(int i=0; i < e.Row.Cells.Count; i++)
{
if (dt.Columns[i].DataType == typeof(System.Int32) || dt.Columns[i].DataType == typeof(System.Decimal))
{
e.Row.Cells[i].HorizontalAlign = HorizontalAlign.Right;
}
}
}
}
Comments