CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    10

    Customizing DataGrid Column in C#

    hi

    i would like to ask a few questions on datagrid columns

    1. how can i change the value before rendering.
    eg: instead of displaying 1,2,3,.., i would like to display "red", "green", "blue",...

    2. can i map 2 or more columns for each column?
    eg: first_name + last_name



    regards
    terence

  2. #2
    Join Date
    Apr 2005
    Posts
    576

    Re: Customizing DataGrid Column in C#

    I don't think that the data grid can do that for you, but you can either use your own classes (you could create a class that wraps a data set or gets data some other way and then show data from that class in the data set), or you could create new columns in your data table and set an expression for the column that does the conversion for you.

  3. #3
    Join Date
    May 2006
    Posts
    203

    Re: Customizing DataGrid Column in C#

    I assume that you are looking for ASP.Net

    If you want to do it in Server side then need to handle the event which will be fired before rendering each row (ItemDataBound or DataBinding event not sure since it's long time back i worked in ASP.Net).

    If it is on Client side then need to have doncitions on the ItemTemplate.

    Still if you have any quries or hiccup please shoot it let me try to help out to you.

    Siva.

  4. #4
    Join Date
    May 2005
    Posts
    10

    Re: Customizing DataGrid Column in C#

    <quote> I assume that you are looking for ASP.Net </quote>

    no no. i'm not looking solution for ASP.NET. this is for C# application....

    <quote> you could create new columns in your data table </quote>

    acutally, i extend a class from DataGridTableSytle.
    Yes, it solves the first problem but not the second one....

    please help.....

    :-(

  5. #5
    Join Date
    Apr 2005
    Posts
    576

    Re: Customizing DataGrid Column in C#

    Second problem is very easy, just add a new column to the data table, set an expression for the column, e.g. first_name + " " + last_name. That's it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured