Solved

Radiobutton list in my Data Grid

Posted on 2006-11-23
9
297 Views
Last Modified: 2012-05-05
Dear all,
           I have radiobuttonlist(sc_rdlShowHide) inside datagrid(sc_dgEmployer). My radiobutton contains 2 options (show,Hide). When user select show, I need count No.of show buttons selected and display in my label control. I am using javascript for this, I call java script function in onclick event of my radiobuttonlist like setValue(this). I am unable pass my radiobuttonlist name to my java script function using keyword 'this'. I have tried in alternative way, but I can't complete the task. I paste my java script code here, kindly go through and find me a solution.

Thank you
Regards
------------------------------------------------------------------------
function setValue(gridname,radioname)
{
      var iIndex=12;
      var CB;
      var oCB;
      var show=0;
      CB = gridname + '__'  + 'ct' + iIndex + '_' + radioname + '_0';
                  
      //sc_dgEmployer__ctl3_sc_rdlShowHide_0 this is name assigned in view source
                  
      oCB = document.getElementById(CB);
      while(oCB)    
      {
      if (oCB.checked == true)
      {
            show++;
      }
      iIndex++;
      CB = gridname + '__'  + 'ct' + iIndex + '_' + radioname + '_0';
      }
            alert(show);    // I am getting zero here
      }
            
0
Comment
Question by:cosKarthik
9 Comments
 
LVL 3

Expert Comment

by:viveksg
ID: 18006171

Please post your html code too.
THere is no need to check radiobuttonlist with its viewsource id. You can use the id that u have given.
0
 

Author Comment

by:cosKarthik
ID: 18006262
OK,

<BODY class="whitebg" onkeydown="javascript:forceSaveButton('sc_cmSave');javascript:OnDisableRefresh();"
            leftMargin="0" topMargin="0" onload="if(history.length>0)history.go(+1);" MARGINHEIGHT="0"
            MARGINWIDTH="0">
<form id="Form1" name="userreg" runat="server">
<INPUT id="hl_StoreSelectedValue" type="hidden" value="0" name="hl_StoreSelectedValue"
                  runat="server">
 <input id="hl_confirmCheck" type="hidden" value="0" name="hl_confirmCheck" runat="server">
<input id="hl_StoreSelectedStatusValue" type="hidden" value="0" name="hl_StoreSelectedStatusValue"
                        runat="server">
<TABLE class="frontendbg" height="100%" cellSpacing="0" cellPadding="0" width="780" align="center"
                  border="0">
      <TBODY>
                              <tr>
      <td class="WhiteBg"><uc1:uctop id="ucTop1" runat="server"></uc1:uctop></td>
                  </tr>
                        <tr>
<td class="frontendbg" height="5"><uc1:ucalerttab id="ucAlertTab1" runat="server"></uc1:ucalerttab></td>
            </tr>
                  <tr>
            <TD width="100%" colSpan="2">
<DIV align="center"><asp:label id="sc_lbErrMsg" CssClass="error1" Runat="server" Visible="False" Width="100%" Font-Bold="True"></asp:label></DIV>
                        </TD>
                              </tr>
                              <tr>
                                    <td colSpan="2" height="20"></td>
                              </tr>
                              <tr>
                                    <td>
<div style="PADDING-LEFT: 25px; FLOAT: left"><asp:hyperlink id="sc_hlBack" CssClass="Link1a_Hand" Runat="server" ImageUrl="images/back.gif"></asp:hyperlink></div>
                                          <div style="PADDING-RIGHT: 25px; FLOAT: right">
<asp:hyperlink id="sc_hlAddNew" CssClass="Link1a_Hand" Runat="server">Add New</asp:hyperlink></div>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
<table class="font1a" cellSpacing="3" cellPadding="2" align="center" border="0">
                                                <tr>
                                                      <td align="right"><b>Center Name</b></td>
                                                      <td class="font1bold"><asp:dropdownlist id="sc_cbCenterName" Runat="server" Width="200px" AutoPostBack="True"></asp:dropdownlist></td>
                                                      <td></td>
                                                </tr>
                                          </table>
                                    </td>
                              </tr>
                              <tr>
<td height="10"><asp:panel id="sc_plCount" Runat="server" Visible="False">
<TABLE class="font1abold" cellSpacing="0" cellPadding="0" width="50%" border="0">
                                                      <TR>
                                                      </TR>
                                                      <TR>
                                                            <TD>
                                                                  <TABLE class="box font1a" cellSpacing="2" cellPadding="4" width="100%">
                                                                        <TR>
                                                                              <TD class="font1abold">Maximum Showable Employer Count</TD>
                                                                              <TD style="PADDING-LEFT: 5px">
                                                                                    <asp:label id="sc_lbEmpMaxCount" Runat="server"></asp:label></TD>
                                                                        </TR>
                                                                        <TR>
                                                                              <TD class="font1abold">Current &nbsp;&nbsp; Showable Employer Count</TD>
                                                                              <TD style="PADDING-LEFT: 5px">
                                                                                    <asp:label id="sc_lbEmpCurCount" Runat="server"></asp:label></TD>
                                                                        </TR>
                                                                  </TABLE>
                                                            </TD>
                                                      </TR>
                                                </TABLE>
                                          </asp:panel></td>
                              </tr>
                              <tr>
<td align="center"><asp:label id="sc_lbMessage" CssClass="message1" Runat="server" Width="490">No
    records were found.</asp:label></td>
                              </tr>
                              <tr>
      <td><asp:panel id="sc_plMain" Runat="server" Height="16px">
      <TABLE class="font1a" cellSpacing="0" cellPadding="1" width="100%" align="center" border="0">
            <TR>
                                                            <TD>
                                                                  <TABLE class="font1a" cellSpacing="0" cellPadding="1" width="70%" align="center" border="0">
                                                                        <TR>
                                                                              <TD align="right">View
                                                            <asp:dropdownlist id="sc_cbEmployerStatus" Runat="server" Width="80" AutoPostBack="True"></asp:dropdownlist></TD>
                                                                        </TR>
                                                                  </TABLE>
                                                            </TD>
                                                      </TR>
                                                      <TR>
                                                            <TD align="center">
                                                            <asp:datagrid id="sc_dgEmployer" Runat="server" Width="70%" EnableViewState="True" AutoGenerateColumns="False"
                                                                        BorderColor="#FFFFFF" BorderWidth="1" CellPadding="2" CellSpacing="0" HeaderStyle-CssClass="altHeading"
                                                                        ItemStyle-CssClass="alternate1a" AlternatingItemStyle-CssClass="alternate2a">
                                                                        <Columns>
                                                                              <asp:TemplateColumn HeaderText="No" HeaderStyle-Width="5%" HeaderStyle-Height="20">
                                                                                    <ItemTemplate>
                                                                                          <% iPuRowNo+=1; %>
                                                                                          <% = iPuRowNo %>
                                                                                    </ItemTemplate>
                                                                              </asp:TemplateColumn>
                                                                              <asp:BoundColumn HeaderText="Employer Name" HeaderStyle-Width="35%" DataField="EMPLOYERNAME"></asp:BoundColumn>
                                                                              <asp:TemplateColumn HeaderText="Status" HeaderStyle-Width="12%">
                                                                                    <HeaderStyle></HeaderStyle>
                                                                                    <ItemTemplate>
                                                                                          <asp:Literal ID="sc_lbStatus" Runat=server Text='<%# DataBinder.Eval(Container.DataItem,"STATUS") %>'>
                                                                                          </asp:Literal>
                                                                                    </ItemTemplate>
                                                                              </asp:TemplateColumn>
                                                                              <asp:TemplateColumn HeaderText="Emp.Type" HeaderStyle-Width="18%">
                                                                                    <HeaderStyle></HeaderStyle>
                                                                                    <ItemTemplate>
                                                      
<asp:Literal ID="sc_ltEmpType" Runat=server Text='<%# DataBinder.Eval(Container.DataItem,"Center_id") %>'>
                                                                                          </asp:Literal>
                                                                                    </ItemTemplate>
                                                                              </asp:TemplateColumn>
                                                                              <asp:TemplateColumn HeaderText="Action" ItemStyle-Width="30%">
                                                                                    <ItemTemplate>
                                                            <asp:Literal Visible="False" id="sc_ltCenterId" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Center_id") %>' >
                                                                                          </asp:Literal>
                                                                                          <asp:Literal Visible="false" Id="sc_ltEmpVisInvis" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"EMPLOYERVISINVIS") %>' >
                                                                                          </asp:Literal>
                                                                                          <table cellpadding="1" cellspacing="1" width="100%" class="font1a" border="0">
                                                                                                <tr>
                                                                                                      <td>
                                                                                                            <asp:Panel ID="sc_pnVisInvis" Runat="server">
                                                                                                                  <ItemTemplate>
                                                            <asp:radiobuttonlist id="sc_rdlShowHide" runat="server" RepeatDirection="Horizontal" AutoPostBack="False"
                                                                                                                              CssClass="font1a" CellPadding="0" CellSpacing="0">
                                                                                                                              <asp:ListItem Value="1">Show</asp:ListItem>
                                                                                                                              <asp:ListItem Value="0">Hide</asp:ListItem>
                                                                                                                        </asp:radiobuttonlist>
                                                                                                                  </ItemTemplate>
                                                                                                            </asp:Panel>
                                                                                                      </td>
                                                                                                      <td>
                                                                                                            <asp:HyperLink ID="sc_hlEdit" Runat="server" CssClass="Link1a_Hand">Edit</asp:HyperLink>
                                                                                                      </td>
                                                                                                </tr>
                                                                                          </table>
                                                                                    </ItemTemplate>
                                                                              </asp:TemplateColumn>
                                                                              <asp:BoundColumn Visible="false" DataField="EMPLOYERID"></asp:BoundColumn>
                                                                        </Columns>
                                                                  </asp:datagrid></TD>
                                                      </TR>
                                                </TABLE>
                                          </asp:panel></td>
                              </tr>
                              <!-- CHECK AND DELETE ABOVE LINE  -->
                              <!-- Nothing below this tag should be changed -->
                              <tr>
                                    <td height="20"></td>
                              </tr>
                              <tr>
                                    <td align="center">
                                          <div style="WIDTH: 115px">
                                                <div style="FLOAT: left"><asp:hyperlink id="sc_hlBack1" CssClass="Link1a_Hand" Runat="server" ImageUrl="images/back_bt.gif"></asp:hyperlink></div>
                                                <div><asp:button id="sc_cmSave" CssClass="formButton" Runat="server" Width="48px" Text="Save "></asp:button></div>
                                          </div>
                                    </td>
                              </tr>
                              <tr>
                                    <td height="20"></td>
                              </tr>
                              <tr>
                                    <td height="100%"></td>
                              </tr>
                              <TR>
                                    <td><uc1:uccopyright id="UcCopyright1" runat="server"></uc1:uccopyright></td>
                              </TR>
                        </TBODY>
                  </TABLE>
            </form>
            </TR></TBODY></TABLE></FORM>
      </BODY>
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18006430
please post the code from the browser (just one example of a table cell is enough), then also tell us which browser you use
0
 
LVL 17

Expert Comment

by:gops1
ID: 18006432
Can you send us the view source of your web page.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:cosKarthik
ID: 18006451
I am using IE,

 view soure

<ItemTemplate>
                                                            
<table id="sc_dgEmployer__ctl2_sc_rdlShowHide" class="font1a" cellspacing="0" cellpadding="0" onclick="javascript:setValue('sc_dgEmployer','sc_rdlShowHide');" border="0" style="border-collapse:collapse;">
                              <tr>
                                    <td><input id="sc_dgEmployer__ctl2_sc_rdlShowHide_0" type="radio" name="sc_dgEmployer:_ctl2:sc_rdlShowHide" value="1" /><label for="sc_dgEmployer__ctl2_sc_rdlShowHide_0">Show</label></td><td><input id="sc_dgEmployer__ctl2_sc_rdlShowHide_1" type="radio" name="sc_dgEmployer:_ctl2:sc_rdlShowHide" value="0" checked="checked" /><label for="sc_dgEmployer__ctl2_sc_rdlShowHide_1">Hide</label></td>
                              </tr>
                        </table>
</ItemTemplate>


<ItemTemplate>
                                                                  <table id="sc_dgEmployer__ctl3_sc_rdlShowHide" class="font1a" cellspacing="0" cellpadding="0" onclick="javascript:setValue('sc_dgEmployer','sc_rdlShowHide');" border="0" style="border-collapse:collapse;">
                              <tr>
                                    <td><input id="sc_dgEmployer__ctl3_sc_rdlShowHide_0" type="radio" name="sc_dgEmployer:_ctl3:sc_rdlShowHide" value="1" checked="checked" /><label for="sc_dgEmployer__ctl3_sc_rdlShowHide_0">Show</label></td><td><input id="sc_dgEmployer__ctl3_sc_rdlShowHide_1" type="radio" name="sc_dgEmployer:_ctl3:sc_rdlShowHide" value="0" /><label for="sc_dgEmployer__ctl3_sc_rdlShowHide_1">Hide</label></td>
                              </tr>
                        </table>
</ItemTemplate>
0
 

Author Comment

by:cosKarthik
ID: 18006476
I got the answer

CB = gridname + '__'  + 'ct' + iIndex + '_' + radioname + '_0';


it actually ctl2,ctl3 but I thought ct12,ct13

Thank you very much for all your response
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18006580
    //sc_dgEmployer__ctl3_sc_rdlShowHide_0 this is name assigned in view source

that's the comment in your function, but the name of the input is actually:

  sc_dgEmployer:_ctl2:sc_rdlShowHide
or
  sc_dgEmployer__ctl3_sc_rdlShowHide_1

also your function is called as
   onclick="javascript:setValue('sc_dgEmployer','sc_rdlShowHide');"
which should be
  onclick="setValue('sc_dgEmployer','sc_rdlShowHide');"

and you use onclick on the table, not the table cell, which may produce problems with some browser's event handling
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18217731
PAQed with points refunded (250)

Computer101
EE Admin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now