By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,432 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,432 IT Pros & Developers. It's quick & easy.

RadioButtonList In A DataGrid Cell - Can I check the slected item without editing the cell?

P: n/a
I have an ASP.NET form with a DataGrid and Button. I want to put a
RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a
ListItem in the cell. The display part works fine. I then check some boxes
and hit the submit button. I can't seem to get the value that is selected on
the RadioButton List. I don't want to use the EditTemplate thing I just want
to click on the radiobutton and submit the form. I also don't want to do
autopostbacks when I click on a button. Can this be done?

I looked at this link:;en-us;320707

I modified the code to work with a RadioButton List not just a RadioButton.
However from each RadioButton List when I cycle throug the GridItems it
tells me that one of the buttons in the list was selected but I can't seem
to get which one.

Here is my test:

using System;

using System.Text;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace DataGridRadio


public class GridList



public GridList() {}

public GridList(

string description,

ArrayList bValue)


this.Description = description;

this.BValue = bValue;



private string description;

private ArrayList bValue;

public string Description


get {return description;}

set {description = value;}


public ArrayList BValue


get {return bValue;}

set {bValue = value;}



public class WebForm1 : System.Web.UI.Page


protected System.Web.UI.WebControls.DataGrid DataGrid1;

protected System.Web.UI.WebControls.Label Message;

protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)


ArrayList blist1 = new ArrayList();

ListItem li1 = new ListItem("aaa", "111");


ListItem li2 = new ListItem("bbb", "222");


ListItem li3 = new ListItem("ccc", "333");

ArrayList blist2 = new ArrayList();

ListItem li4 = new ListItem("ddd");


ListItem li5 = new ListItem("eee");


ListItem li6 = new ListItem("fff");


ArrayList blist3 = new ArrayList();

ListItem li7 = new ListItem("ggg");


ListItem li8 = new ListItem("hhh");


ListItem li9 = new ListItem("iii");


ArrayList alist1 = new ArrayList();

GridList gl1 = new GridList("aaaaaaaaaaa", blist1);


GridList gl2 = new GridList("bbbbbbbbbbb", blist2);


GridList gl3 = new GridList("ccccccccccc", blist3);


DataGrid1.DataSource = alist1;



#region Web Form Designer generated code

override protected void OnInit(EventArgs e)



// CODEGEN: This call is required by the ASP.NET Web Form Designer.




/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()


this.Button1.Click += new System.EventHandler(this.Button1_Click);

this.Load += new System.EventHandler(this.Page_Load);



private void Button1_Click(object sender, System.EventArgs e)


StringBuilder gridSelections = new StringBuilder();

//Loop through each DataGridItem, and determine which CheckBox controls

//have been selected.

foreach(DataGridItem DemoGridItem in DataGrid1.Items)


RadioButtonList myRadioButtonList =


bool b4 = myRadioButtonList.Items[1].Selected;

int b1;

b1 = myRadioButtonList.SelectedIndex;

ListItem b2 = new ListItem();

b2 = myRadioButtonList.SelectedItem;

int b3 = 2;





Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.