Gridview RowDataBound: get original cell value not formatted string?

Last post 04-10-2008 4:24 PM by tmpuzer. 1 replies.

Sort Posts:

  • Gridview RowDataBound: get original cell value not formatted string?

    04-10-2008, 3:54 PM
    • Loading...
    • tmpuzer
    • Joined on 03-07-2008, 12:45 PM
    • Posts 328

     I have gridview with several columns one of which is percent column.  This is bound to a column with a SQL float data type.  I format the number to be a percent string:

    So the column in the database has the value of 50.0 and the gridview displays this as "50%".
    e.Row.Cells[0].Text returns the formatted string "50%"

    When handling the RowDataBound event how can I access the original data value of cell, 50.0, rather than the formatted string, "50%"?


    If a post helps me I'll always eventually mark it as an answer. But I frequently don't mark it right away because I feel once a thread is marked as answered, discussion tends to end. And I like to discuss things a bit.
    Filed under: ,
  • Re: Gridview RowDataBound: get original cell value not formatted string?

    04-10-2008, 4:24 PM
    Answer
    • Loading...
    • tmpuzer
    • Joined on 03-07-2008, 12:45 PM
    • Posts 328

     I found the answer to my own question ( found it here http://msdn2.microsoft.com/en-us/library/aa479353.aspx).  I can use the DataItem property like so:

    string temp = ((DataRowView)e.Row.DataItem)["<column_name>"].ToString(); 

     

    If a post helps me I'll always eventually mark it as an answer. But I frequently don't mark it right away because I feel once a thread is marked as answered, discussion tends to end. And I like to discuss things a bit.
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter