Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 1.60 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to change Column Width of GridView programically
  2. DataClassesDataContext dContext = new DataClassesDataContext();
  3.             var userId = (Guid)(Membership.GetUser(Membership.GetUser().UserName, false).ProviderUserKey);
  4.             var tekovenKorisnikQuery = from d in dContext.pregledIshranas
  5.                               where d.UserId == userId
  6.                               select new {d.datum, d.kilogrami, d.visina, d.BMI, d.kalorii};
  7.  
  8.             List<PregledIshranaFormatirano> listaFormatirana = new List<PregledIshranaFormatirano>();
  9.             foreach (var d in tekovenKorisnikQuery)
  10.             {
  11.                 listaFormatirana.Add(new PregledIshranaFormatirano(string.Format("{0:dd-MM-yyyy}", d.datum), d.kilogrami.ToString(), d.visina.ToString(), string.Format("{0:N2}", d.BMI), d.kalorii.ToString()));
  12.             }
  13.  
  14.             gvTekovenKorisnik.DataSource = listaFormatirana;
  15.             gvTekovenKorisnik.DataBind();
  16.        
  17. protected void gvTekovenKorisnik_RowDataBound(object sender, GridViewRowEventArgs e)
  18.     {
  19.  
  20.         if (e.Row.RowType == DataControlRowType.Header)
  21.         {
  22.             e.Row.Cells[0].Width = new Unit("200px");
  23.             e.Row.Cells[0].Text = "Датум";
  24.             e.Row.Cells[1].Width = new Unit("200px");
  25.             e.Row.Cells[1].Text = "Килограми";
  26.             e.Row.Cells[2].Width = new Unit("200px");
  27.             e.Row.Cells[2].Text = "Висина";
  28.             e.Row.Cells[3].Width = new Unit("200px");
  29.             e.Row.Cells[3].Text = "BMI индекс";
  30.             e.Row.Cells[4].Width = new Unit("200px");
  31.             e.Row.Cells[4].Text = "Калории";