Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
Radio Buttons in Grid Row
posted

I'm trying to use the WebGrid control with three radio buttons on each row.  They are labeled "Exclude Time", "Stop", and "Complete".  These will be unbound controls.  Is it possible to put radio buttons on a WebGrid so the user can select only one of the three choices?  If radio buttons aren't available, is there a different control I should use to achieve this result?

Parents
  • 275
    Verified Answer
    Offline posted

    I got the radio buttons on the grid by adding the code below to the grid markup:

    <ig:TemplateDataField Key="TemplateField_Status">
    <Header Text="Status">
    </Header>
    <ItemTemplate>
    <asp:RadioButtonList ID="rblStatus" runat="server" RepeatDirection="Horizontal">
    <asp:ListItem Selected="True" style="padding-right:25px;">Exclude Time</asp:ListItem>
    <asp:ListItem style="padding-right:25px;">Stop</asp:ListItem>
    <asp:ListItem>Complete</asp:ListItem>
    </asp:RadioButtonList>
    </ItemTemplate>
    </ig:TemplateDataField>

    I have a button on the web page, on when the OnClick event is fired for the button the following code shows me which radio button the user selected for each row:

    WebDataGrid grid = WeldsDataGrid;
    RadioButtonList rbl_response;

    foreach (GridRecord row in grid.Rows)
    {
    rbl_response = (RadioButtonList)row.Items[4].FindControl("rblStatus");
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + weld + " - " + rbl_response.SelectedValue + "')", true);
    }

Reply Children
No Data