Click here to Skip to main content
15,886,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to display Check box from database in grid view as field is not Bit type .
Without saving data set(database values) in view state how to set checkbox from database values .
Posted
Comments
Maciej Los 29-Oct-14 10:15am    
What have you tried? Where are you stuck?
sp_suresh 30-Oct-14 5:16am    
Thanks for reply.
Suppose an student has given many exam ID from options and then I save into database.After then when he returns on same page he must display which exam ID he has selected.How to achieve this?I tried by saving datatable in viewstate and then calling this in rowdatabound event this will become successfull but is this causes performance as data is stored in Viewstate?if no i can go ahead else give me solution.

1 solution

A simple google search should get you tons and tons of examples.

See http://stackoverflow.com/questions/18482132/how-to-bind-check-box-values-on-gridview-with-the-values-of-database-table[^] for an example.
 
Share this answer
 
Comments
sp_suresh 29-Oct-14 8:10am    
Hey, please see that Field is not Bit Type so that i can bind data directly.I cant use Eval here.Field is of int Type (ID) .Suppose an student has given many exam ID from options and then I save into database.After then when he returns on same page he must display which exam ID he has selected.How to achieve this?
ZurdoDev 29-Oct-14 8:12am    
In your SQL, you need to return the proper value for each column.
sp_suresh 30-Oct-14 5:18am    
how?pl give me example if i have column having integer value inserted into table and then I have to display acc to this data against default gridview row
ZurdoDev 30-Oct-14 7:38am    
It's your data so I can't tell you how.

However, perhaps something like

CASE WHEN field1 > 3 THEN 1 ELSE 0 END AS field1, etc, etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900