How to put a full radio button list in each row of datagrid?

Discussion in 'ASP .Net Datagrid Control' started by John Smith, Aug 20, 2003.

  1. John Smith

    John Smith Guest


    I have a datagrid where I display images. I want visitors to be able
    to rate the images on a scale of 1 to 10 by clicking a radio button,
    which will cause an auto-postback. In that auto-postback event, I
    want to be able to identify which row caused it, and determine which
    value was selected. Then I want to write that information to a

    All the examples I have found concerning radio button lists and the
    datagrid have to do with putting one radio button per row, to let
    users select the row. My request is different, in that in each row,
    there will be one radio button list with 10 buttons, from 1 to 10.

    I can put the radio button list in the datagrid, and the auto-postback
    feature does cause the form to post (because the screen blinks), but I
    don't know the name of the raised event, so I can't begin to write the
    handler. Also, I wouldn't know how to get the row and the value, thus
    my posting here.

    Thank you very much.

    John Smith, Aug 20, 2003
    1. Advertisements

  2. I have a similiar situation here's what I did:

    In my datagrid I added these columns:

    <asp:RadioButton id="rdBtnAccept" Text="Yes" Runat="server"
    GroupName="Accept" AutoPostBack="True" OnCheckedChanged="rdbtnCheckChg">
    <asp:RadioButton id="rdBtnDeny" Text="No" Runat="server"

    Then in my code behind file:

    public void rdbtnCheckChg(object sender, System.EventArgs e)
    RadioButton myBtn = (RadioButton)sender;
    DataGridItem myGridItem = (DataGridItem)myBtn.Parent.Parent;
    grdTrips.Columns[1].Visible = true;
    grdTrips.EditItemIndex = myGridItem.ItemIndex;

    You will also have to add an EditCommandColumn to generate the OnUpdate
    event to write to the database, you can specify your event handler for this
    event in your aspx file: <asp:DataGrid id="myGrid"
    OnUpdateCommand="myUpdateHandler" ...>

    David Churchill
    David Churchill, Aug 20, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.