【转自】http://hi.baidu.com/zck98530/blog/item/a873b1b7a6911cf430add141.html
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.Item)
{
Label lb=(Label)e.Item.FindControl("Label1");
lb.Text="<input type=radio name='myradio' value=" + e.Item.Cells[1].Text + ">";
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
string text=Request.Form["myradio"].ToString();
foreach (DataGridItem dgi in DataGrid1.Items)
{
if(dgi.ItemType==ListItemType.AlternatingItem || dgi.ItemType==ListItemType.Item)
{
Label lbb=(Label)dgi.FindControl("Label1");
if(lbb.Text.IndexOf(text)>0)
{
lbb.Text="<input type=radio name='myradio' value=" + dgi.Cells[1].Text + " checked>";
Response.Write(dgi.Cells[1].Text);
}
else
{
lbb.Text="<input type=radio name='myradio' value=" + dgi.Cells[1].Text + ">";
}
}
}
}