asp.net gridview单选按钮

时间:2010-11-01 10:04:59

标签: asp.net gridview radio-button

http://www.asp.net/data-access/tutorials/adding-a-gridview-column-of-radio-buttons-cs

请参阅以上链接。如何以编程方式选择RadioButton?

1 个答案:

答案 0 :(得分:0)

void SetPrimaryContactID()
{
    if (grvCustomerContact.Rows.Count > 0)
    {
        foreach (GridViewRow gr in grvCustomerContact.Rows)
        {
            Label l = (Label)gr.FindControl("lblContacts_ID");
            bool s = hd_PrimaryContact.Value.Equals(l.Text);
            if (hd_PrimaryContact.Value.Equals(l.Text))
            {
                Literal output = (Literal)gr.FindControl("RadioButtonMarkup");
                output.Text = string.Format(@"<input type='radio' name='PrimaryConactGroup'" + @"id='RowSelector{0}' value='{0}' checked='checked' />", gr.RowIndex);
            }
        }

    }
}