473,471 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to set radio button in datagrid?

Hi experts,

I have a little problem with datagrid needing your expertise.

In database, I have a column called "Active" which has only 2 values "Yes"
and "No". In my application, I want to show the value in redio format so that
user can simply click "Yes" or "No" to switch value. But I don't know how to
set the data format for a column in the dataset. Can you share ms some of
your experience about it?

Thanks,

Karl
Nov 16 '05 #1
2 7285
Hi,

You can set it to bool (true/false = yes/no).

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Karl" <Ka**@discussions.microsoft.com> je napisal v sporočilo
news:C0**********************************@microsof t.com ...
Hi experts,

I have a little problem with datagrid needing your expertise.

In database, I have a column called "Active" which has only 2 values "Yes"
and "No". In my application, I want to show the value in redio format so
that
user can simply click "Yes" or "No" to switch value. But I don't know how
to
set the data format for a column in the dataset. Can you share ms some of
your experience about it?

Thanks,

Karl

Nov 16 '05 #2
Karl,

I assume that you don't have the option of handling and storing your value
as a boolean (bit in SQL Server) in your database which is, IMHO, the best
thing to do.

If that is correct then, alternatively, you could set the Checked property
of the RadioButton to the result of the following statement:

string.Compare(stringDatabaseValue, "Yes", true) == 0;

or use a case statement in the stored procedure that fills your dataset so
that you can return a 1 or 0 for Yes or No and then set RadioButton.Checked
to

Convert.ToBoolean(intDatabaseValue);

In your Update stored procedure use a case statement again like this:

CASE WHEN @ButtonValue = 1 THEN 'Yes' ELSE 'No'

Another option is to add a DataColumn to the table you're using with the
DataType property set to System.Type.GetType("System.Boolean"). Then
iterate through your rows and set the new boolean column using the
statements I showed above.

The point is, the data you're talking about is not a string, it is a
boolean: Yes/No... Two states. You're manipulating it as a boolean: Checked
= true/false... Two states. Yet, you're storing it as a string. That is
always going to cause you a problem. Store your data according to what it
is and let the UI, in this case the labels on your RadioButtons handle the
user interface portion, as it is designed to do.

HTH

DalePres
MCAD, MCDBA, MCSE
"Peter Jausovec" <pe***@jausovec.net> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
Hi,

You can set it to bool (true/false = yes/no).

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Karl" <Ka**@discussions.microsoft.com> je napisal v sporočilo
news:C0**********************************@microsof t.com ...
Hi experts,

I have a little problem with datagrid needing your expertise.

In database, I have a column called "Active" which has only 2 values
"Yes"
and "No". In my application, I want to show the value in redio format so
that
user can simply click "Yes" or "No" to switch value. But I don't know how
to
set the data format for a column in the dataset. Can you share ms some of
your experience about it?

Thanks,

Karl


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tim C | last post by:
I am trying to bind a dataset to a datagrid. I would like for the first column in the datagrid to be a radio button. I have included an item template and the radio buttons are rendered, but...
14
by: Steve Chatham | last post by:
I have a combo box that gets populated with a group of items based on a sql table. I had in mind that I'd insert a value at the beginning of that combo box, that'd say "No Item Selected" and...
2
by: MR. UNDERHILL | last post by:
I want to use a radio button as a template column in a data grid, what is happening is that the exclusive selection is not working since the internal radio button name is being generated by the...
1
by: walterd | last post by:
Hi I have a DataGrid with dynamically created Radio Buttons using ItemTemplate. How can I catch the Click Event for the selected Radio Button in Client Side? I need to perform some validation...
2
by: tshad | last post by:
I have 2 radio buttons: <asp:RadioButton ID="radDetail" GroupName="detailSummary" Text="Detail" checkedChanged="RadDetail_Clicked" runat="server" /> <asp:RadioButton ID="radSummary"...
3
by: David Hearn | last post by:
I have a datalist that I have inserted a radio button into. The datalist populates with a list of items and each one has a radio button next to it. I need to use the radio button to allow the user...
5
by: Samy | last post by:
Hi There, I have a label in a datagrid which I make it a input type = radio in ItemDataBound so that radio buttons are shown in the datagrid. This is how I have it... ASPX... <asp:Label...
2
by: JimS | last post by:
I am using DotNet 2.0 and Visual Studio 2005. The project is a web project. I am currently using an ObjectDataSource to populate a datagrid. The ObjectDataSource is configured to a function in a...
2
by: harini | last post by:
hi, i have a radio button. On clicking the radio button i have to clear the already existing tablestyle of my datagrid and bind a new table to the grid with a new tablestyle. i used, ...
0
by: aroraamit81 | last post by:
Hi, I have a RadioButton column in a DataGrid, the problem is it is allowing me to multi select RadioButtons, where as I dont want to have post back on Click of radio Button. Here is a code...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.