GetCellValue for Visual Baisc?

Discussion in 'ASP .Net Web Controls' started by jonefer, May 25, 2007.

  1. jonefer

    jonefer Guest

    I found this excellent article of Formatting AutoGenerateColumns in ASP.NET
    Grid - The code project written in C#

    I converted it into Visual Basic for my project
    But it says that GetCellValue needs to be declared

    Here's the code with the GetCellValue method
    private void GV_RowDataBound(object o, GridViewRowEventArgs e)
    {
    // apply custom formatting to data cells
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    // set formatting for the category cell
    TableCell cell = e.Row.Cells[0];
    cell.Width = new Unit("120px");
    cell.Style["border-right"] = "2px solid #666666";
    cell.BackColor = System.Drawing.Color.LightGray;

    // set formatting for value cells
    for(int i=1; i<e.Row.Cells.Count; i++)
    {
    cell = e.Row.Cells;

    // right-align each of the column cells after the first
    // and set the width
    cell.HorizontalAlign = HorizontalAlign.Right;
    cell.Width = new Unit("90px");

    // alternate background colors
    if (i % 2 == 1)
    cell.BackColor
    = System.Drawing.ColorTranslator.FromHtml("#EFEFEF");

    // check value columns for a high enough value
    // (value >= 8000) and apply special highlighting
    if (GetCellValue(cell) >= 8000)
    {
    cell.Font.Bold = true;
    cell.BorderWidth = new Unit("1px");
    cell.BorderColor = System.Drawing.Color.Gray;
    cell.BorderStyle = BorderStyle.Dotted;
    cell.BackColor = System.Drawing.Color.Honeydew;
    }

    }
    }

    // apply custom formatting to the header cells
    if (e.Row.RowType == DataControlRowType.Header)
    {
    foreach (TableCell cell in e.Row.Cells)
    {
    cell.Style["border-bottom"] = "2px solid #666666";
    cell.BackColor=System.Drawing.Color.LightGray;
    }
    }

    }
    jonefer, May 25, 2007
    #1
    1. Advertising

  2. jonefer

    Manish Bafna Guest

    Hi,
    What i am telling is very basic thing but somehow if you have missed then
    try doing this:
    You need to download full code by clicking on link at top "Download
    Formatting Samples and Extender Source".In that you will find the code for
    custom function GetCellValue.
    Hope this helps
    --
    Hope this helps.
    Thanks and Regards.
    Manish Bafna.
    MCP and MCTS.



    "jonefer" wrote:

    > I found this excellent article of Formatting AutoGenerateColumns in ASP.NET
    > Grid - The code project written in C#
    >
    > I converted it into Visual Basic for my project
    > But it says that GetCellValue needs to be declared
    >
    > Here's the code with the GetCellValue method
    > private void GV_RowDataBound(object o, GridViewRowEventArgs e)
    > {
    > // apply custom formatting to data cells
    > if (e.Row.RowType == DataControlRowType.DataRow)
    > {
    > // set formatting for the category cell
    > TableCell cell = e.Row.Cells[0];
    > cell.Width = new Unit("120px");
    > cell.Style["border-right"] = "2px solid #666666";
    > cell.BackColor = System.Drawing.Color.LightGray;
    >
    > // set formatting for value cells
    > for(int i=1; i<e.Row.Cells.Count; i++)
    > {
    > cell = e.Row.Cells;
    >
    > // right-align each of the column cells after the first
    > // and set the width
    > cell.HorizontalAlign = HorizontalAlign.Right;
    > cell.Width = new Unit("90px");
    >
    > // alternate background colors
    > if (i % 2 == 1)
    > cell.BackColor
    > = System.Drawing.ColorTranslator.FromHtml("#EFEFEF");
    >
    > // check value columns for a high enough value
    > // (value >= 8000) and apply special highlighting
    > if (GetCellValue(cell) >= 8000)
    > {
    > cell.Font.Bold = true;
    > cell.BorderWidth = new Unit("1px");
    > cell.BorderColor = System.Drawing.Color.Gray;
    > cell.BorderStyle = BorderStyle.Dotted;
    > cell.BackColor = System.Drawing.Color.Honeydew;
    > }
    >
    > }
    > }
    >
    > // apply custom formatting to the header cells
    > if (e.Row.RowType == DataControlRowType.Header)
    > {
    > foreach (TableCell cell in e.Row.Cells)
    > {
    > cell.Style["border-bottom"] = "2px solid #666666";
    > cell.BackColor=System.Drawing.Color.LightGray;
    > }
    > }
    >
    > }
    Manish Bafna, May 25, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Timbers
    Replies:
    32
    Views:
    1,387
    Alvin Bruney
    Nov 8, 2003
  2. raj mandadi
    Replies:
    0
    Views:
    414
    raj mandadi
    Dec 22, 2003
  3. Ken Williams

    ActiveX with Visual Baisc .NET 2003?

    Ken Williams, Mar 6, 2004, in forum: HTML
    Replies:
    3
    Views:
    867
    Dick O'Brien
    Mar 6, 2004
  4. Replies:
    4
    Views:
    465
    Darren Kopp
    May 22, 2006
  5. Baisc One

    , Apr 24, 2007, in forum: Java
    Replies:
    9
    Views:
    382
    Eric Sosman
    Apr 26, 2007
Loading...

Share This Page