This is a migrated thread and some comments may be shown as answers.

Insert a column with a checkbox and two radiobuttons

5 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 27 Mar 2009, 07:03 AM
What is the best way to insert via codebehind a column with a checkbox and two radiobuttons into a grid?

with GridTemplateColumn and GridTemplateColumn?

Christian

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2009, 07:39 AM
Hi,

You can use a GridTemplateColumn to achieve the desired scenario. Go through the following forum link which explains how to add a GridTemplateColumn in the code behind.
Programmatic creation

Shinu
0
Christian
Top achievements
Rank 1
answered on 27 Mar 2009, 08:49 AM
Perhaps a simple question:

When I bind the data as shown in the article, how can I then get in the codebehind the information which Radiobutton the user has selected?

thanks
Christian
0
Princy
Top achievements
Rank 2
answered on 27 Mar 2009, 10:14 AM
Hi Christian,

Try attaching the same CheckChanged event handler for the both the RadioButtons and you can identify the currently Checked RadioButton inside the CheckChanged event as shown below.

CS:
 
 
            RadioButton1.AutoPostBack = true
            RadioButton2.AutoPostBack = true
            RadioButton1.CheckedChanged += new EventHandler(RadioButton1_CheckedChanged); 
            RadioButton2.CheckedChanged += new EventHandler(RadioButton1_CheckedChanged); 

 
 void RadioButton1_CheckedChanged(object sender, EventArgs e) 
    { 
        RadioButton RadBtn = (RadioButton)sender; 
        string RadBtnID = RadBtn.ID; 
    } 

Thanks
Princy

0
Christian
Top achievements
Rank 1
answered on 27 Mar 2009, 10:27 AM
Hi Princy,

thanks for the code.

Your solution means that each time the user clicks on a radiobutton ths fires a postback to the server. We have much data and when the user clicks on many buttons then this need (to much) time.

Are there any other possibilities to get the information about the checked radiobuttons after the submit of the page?

thanks

Christian
0
Christian
Top achievements
Rank 1
answered on 29 Mar 2009, 09:46 AM
Is this a good idea?
 
- create a javascript-event onclick for each Radiobutton and checkbox.
- with the Javascript-onclick event I remember the clicked radiobutton and write it in a hidden textfield
- after the submit I read the textfield in the code behind and write the changes into the dataset

thanks
Christian
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Christian
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or