Data Binding - ASP 2.0

Discussion in 'ASP .Net Datagrid Control' started by dm1608, Feb 13, 2006.

  1. dm1608

    dm1608 Guest

    I'm binding a column to a datagrid and would like to convert the column to
    uppercase.

    I notice that if I edit the GridView column, I can add formatting such as
    {0:d} and {0:c} to the data item.

    How can I convert this item to Uppercase?

    I suppose I could do it via SQL, but I want to know how to do it using code.

    Thanks
    dm1608, Feb 13, 2006
    #1
    1. Advertising

  2. If you want formatting that isn't covered by the format strings, your
    best bet is to handle the databinding events of your GridView.

    <code>

    protected void MyGridView_RowDataBound(object sender,
    GridViewRowEventArgs e)
    {
    const myUppercaseColumnIndex = 1;
    // don't handle headers or footers
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
    e.Row.Cells[myUppercaseColumnIndex].Text =
    e.Row.Cells[myUp..].ToUpper();
    }
    }

    </code>
    Flinky Wisty Pomm, Feb 14, 2006
    #2
    1. Advertising

  3. dm1608

    dm1608 Guest

    Thanks for the response.

    I have a couple issues though --

    1) It didn't like the const line. Something about the = sign and receiving
    an "no identifier" message. I simply hardcoded the column for now.

    2) Apparently the ToUpper() function is not part of the Cell class or
    whatever. No worky??


    Also, where did you obtain the Grid events info, etc? Are there any books
    that reference how to do all these things.

    This is really cool stuff.


    Thanks



    "Flinky Wisty Pomm" <> wrote in message
    news:...
    > If you want formatting that isn't covered by the format strings, your
    > best bet is to handle the databinding events of your GridView.
    >
    > <code>
    >
    > protected void MyGridView_RowDataBound(object sender,
    > GridViewRowEventArgs e)
    > {
    > const myUppercaseColumnIndex = 1;
    > // don't handle headers or footers
    > if(e.Row.RowType == DataControlRowType.DataRow)
    > {
    > e.Row.Cells[myUppercaseColumnIndex].Text =
    > e.Row.Cells[myUp..].ToUpper();
    > }
    > }
    >
    > </code>
    >
    dm1608, Feb 14, 2006
    #3
    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. Jordan
    Replies:
    2
    Views:
    2,518
    Jordan
    Feb 10, 2004
  2. Amit
    Replies:
    6
    Views:
    13,754
    Assimalyst
    Oct 24, 2006
  3. Replies:
    2
    Views:
    842
    Kevin Grover
    Oct 20, 2006
  4. JcFx
    Replies:
    0
    Views:
    265
  5. Vivek Nallur

    value binding and function binding

    Vivek Nallur, Sep 25, 2003, in forum: Ruby
    Replies:
    0
    Views:
    129
    Vivek Nallur
    Sep 25, 2003
Loading...

Share This Page