views:

359

answers:

0

i gt a radio button inside my datalist through which i am evaluating id in hiddenfield like this

<ItemTemplate>

                <table cellpadding = "1px" cellspacing = "0" class="dlTable">
                <tr>
                <td align="center"  style="padding:15px">
                <a href="<%#Eval("FilePath")%>" target="_blank"><asp:Image ID="Image1" runat="server" CssClass="imu" ImageUrl = '<%# Eval("FilePath")%>' 
                Width = "80px" Height = "80px" style ="cursor:pointer" />
                </td>            
                </tr>
                <tr >
                <td align="center" > 

                <asp:RadioButton ID="rdb" runat="server"  OnCheckedChanged="rdb_click" AutoPostBack="true"  CssClass="radio" />                  
                <asp:HiddenField ID="HiddenField1" runat="server" Value = '<%#Eval("ID")%>' /> 
                </td>
                </tr>                     
                </table>

 </ItemTemplate>

in codebehind i have this...

protected void rdb_click(object sender, EventArgs e)
        {

                for (int i = 0; i < DataList1.Items.Count; i++)
                {
                    RadioButton rdb;
                    rdb = (RadioButton)DataList1.Items[i].FindControl("rdb");
                    if (rdb != null)
                    {
                        if (rdb.Checked)
                        {
                            HiddenField hf = (HiddenField)DataList1.Items[i].FindControl("HiddenField1");
                             Label5.Text = hf.Value.ToString();
                        }

                    }
                }

now this isworking but when autopostback set to true

is there any way to evaluate hiddenfield using javascript..so that i can avoid postback