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;
                    }
                }              
            }
        }

Comments

Popular posts from this blog

what is Event Cache table in sharepoint

CAML Query syntax and options in SharePoint

Change anchor link url in sharepoint calender