473,776 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mapping Custom Data in Gridview

3 New Member
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
Sep 15 '07 #1
2 1435
jhardman
3,406 Recognized Expert Specialist
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:
Expand|Select|Wrap|Line Numbers
  1. query = "SELECT * FROM users, genders WHERE users.genderNum = genders.genderNum"
  2.  
  3. rs.open query, conn
  4.  
  5. response.write rs("genders.genderName")
or I would populate an array with the possible choices like this:
Expand|Select|Wrap|Line Numbers
  1. dim fruits(6)
  2.  
  3. fruits(0) = "banana"
  4. fruits(1) = "apple"
  5. 'etc
  6.  
  7. response.write fruits(rs("fruitNum"))
Let me know if this helps.

Jared
Sep 16 '07 #2
mzmishra
390 Recognized Expert Contributor
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
Sep 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1328
by: paul.phillips | last post by:
Hi, please can someone help me? I have created a custom web control that renders GridView, which it does (e.g. I can see data in the grid). The problem is this, how do I add a Select command button to the grid within the Custom Web Server Control which posts back with a command argument with "Select". Currently if I add button to the GridView then, it generates the button
0
1679
by: Khuzema | last post by:
Dear All, I am using issue tracker architecture and developed business object for my application. Now, in VS Beta 2, I humbly want to know how i can have same feature as dataset, in my business object, what i mean is, if you have dataset object and assign it to gridview, you can add/edit/delete row (without affecting table) and then post it back to database. Same thing i want to have for my business object (which is generic collection)...
8
5041
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
3
2029
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my project and I get the same errors there: Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.
1
11720
by: WebMatrix | last post by:
Hi, I started a new web application which so far has several grdiviews displaying data. I find myself reimplementing the same logic (copy/pasting really) in grid's event ItemDataBound and RowCreated and Sorting events to add certain effects. For example inserting sorting direction image to the column header. I want to create one custom grid view that implement all this logic to be reused through out this app, so I wont need to copy...
2
8992
by: Greg | last post by:
Hello, I am trying to bind a GridView to a custom object I have created. First, here is what I'm trying to do: I have a wizard for adding/editing Users. When the wizard begins, a User object (custom class) is created, and properties are populated in each step of the wizard. In one of the steps, the User is assigned to 1 or more Programs. Assigned Programs are stored by the User object in a List, and displayed in a GridView in the...
1
1747
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following simple statements to actually generate something at design-time: gridView = new GridView(); gridView.AutoGenerateColumns = true; gridView.DataSource = ; gridView.DataBind(); I have tried everything I could think of, or read about in four books...
0
1220
by: =?Utf-8?B?QVZM?= | last post by:
Hi, I've a requirement in which I want to use the custom sorting.. I mean I've a dropdown with sortable column names and when the user selects the particular column from dropdown , I need to sort the grid. For it,Im trying to get the gridView.DataSource() to retrieve the datatable attached to it (Ive earlier binded the gridview in page load in not postback section ) , but gridView.DataSource() always returning null.. Im unable to...
16
4018
by: pupilstuff | last post by:
hi guys i just want to perform custom paging in which at the footer of the grid view ,there must be a pager 'pervious/next with numeric' this is what i did in aspx page <asp:GridView ID="TableGridView" OnPageIndexChanging="TableGridView_PageIndexChanging" runat="server" AutoGenerateColumns="False"
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8952
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.