How to modify my data to something else in Gridview??

armansiu

New member
Joined
Jun 8, 2006
Messages
1
Programming Experience
Beginner
Hi, experts,
currently I am using Gridview to display my data on my application. The thing I want to do is, I want to map the data to a string. Just like one of my columns will have the value of 3, but I want to display "Deleted" on the screen instead of "3". Is it possible? I am putting all the codes in the vb file, even the declaration of the asp.net web control. Will this work? or i have to define it in the aspx page? Please help. Thanks
 
i dont know about asp.net, but in windows forms, in your datagridview properties, you have the COLUMNS property

this is a collection. open the editor for the collection by clicking the [...] button and change the column type to GridViewComboBox
set the datasource of this combobox to be a datatable that has your map values in (suppose you have a datatable called TheMap, with columns val and disp. a row contains 3 and Deleted respectively)
Now set the displaymember of the combo to the DISP column and the ValueMember of the combo to the VAL column

and it's done.

note the grid will get very upset if your data contains values that are not in the map. provide some error handling for this case
 
Back
Top