Mapping Custom Data in Gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jayesch
    New Member
    • Sep 2007
    • 3

    #1

    Mapping Custom Data in Gridview

    I am using data sets in my project to fetch data from Access database and I bind these dataset APIs to gridview. My problem is - I have certain boolean data and numerical data that I need to map it to user presentable text. For e.g. say if I use gender as boolean data then 1(True) - should be displayed as "male" and 0 (false) should be displayed as "female". The other example is say I wish to store name of fruits as numbers in my database to save some memory. Then 0 - should be displayed as - Apple, 1 as - Oranges, 2 - Peach etc. For this I defined a hash table which would contain a mapping of the numerical values to the presentable text. Now I am not sure how to present values from hash table to the web page in grid view.

    Thanks in advance
    Jayesh
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Jayesh,

    I am moving this question to the .NET forum, since this is a .NET question. In ASP classic I would either link this data to a second db table like this:
    [code=asp]query = "SELECT * FROM users, genders WHERE users.genderNum = genders.genderN um"

    rs.open query, conn

    response.write rs("genders.gen derName")[/code]
    or I would populate an array with the possible choices like this: [code=asp]dim fruits(6)

    fruits(0) = "banana"
    fruits(1) = "apple"
    'etc

    response.write fruits(rs("frui tNum"))[/code]Let me know if this helps.

    Jared

    Comment

    • mzmishra
      Recognized Expert Contributor
      • Aug 2007
      • 390

      #3
      You can do like this
      1.Create a DataTable like DataTable table = dataset.Tables[0]
      2. add one more column to datatable which will containg the value from your HashTable.
      3.you can add the values from Hashtable to this column
      4.Make this table your grid datasource

      Comment

      Working...