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. Advertisements

  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. Advertisements

  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. Advertisements

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. =?Utf-8?B?cG9wc292eUBydXNtZXguY29t?=

    Using Data Binding to save data

    =?Utf-8?B?cG9wc292eUBydXNtZXguY29t?=, Jan 30, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    521
    =?Utf-8?B?cG9wc292eUBydXNtZXguY29t?=
    Jan 30, 2004
  2. Jordan
    Replies:
    2
    Views:
    2,765
    Jordan
    Feb 10, 2004
  3. Kostia
    Replies:
    0
    Views:
    434
    Kostia
    Apr 27, 2004
  4. Amit
    Replies:
    6
    Views:
    14,285
    Assimalyst
    Oct 24, 2006
  5. Replies:
    2
    Views:
    1,088
    Kevin Grover
    Oct 20, 2006
  6. JcFx
    Replies:
    0
    Views:
    541
  7. vineetbatta

    Binding data to Grid control with CUSTOM DATA CLASS

    vineetbatta, Oct 16, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    869
    vineetbatta
    Oct 16, 2006
  8. Vivek Nallur

    value binding and function binding

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