Professional Web Applications Themes

How to put a full radio button list in each row of datagrid? - ASP.NET Data Grid Control

Hello, 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 database. 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, ...

  1. #1

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

    Hello,

    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
    database.

    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
    John Smith Guest

  2. #2

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

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

    In my datagrid I added these columns:

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

    Then in my code behind file:

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

    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" ...>

    HTH,
    David Churchill

    "John Smith" <ruupacbell.net> wrote in message
    news:98133416.0308191510.11ed6deeposting.google.c om...
    > Hello,
    >
    > 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
    > database.
    >
    > 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

    David Churchill Guest

Similar Threads

  1. Radio Button & List to search - ASP
    By Tag2007 in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: July 27th, 11:01 AM
  2. radio button list doesn't hold value?
    By KathyB in forum ASP.NET General
    Replies: 2
    Last Post: August 12th, 02:46 AM
  3. how to make columns the same size in a radio button list
    By Trevor Hartman in forum ASP.NET General
    Replies: 1
    Last Post: August 1st, 05:55 PM
  4. Programmatically Selecting Item in Radio Button List
    By John Criswell in forum ASP.NET General
    Replies: 1
    Last Post: July 24th, 07:07 PM
  5. Radio Button List server control and java script
    By jayuya in forum ASP.NET General
    Replies: 2
    Last Post: July 3rd, 08:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139