Specializations

Wednesday, November 14, 2012

selected row ingridview

Asp.Net Grid views
<asp:TemplateField>
                                                <HeaderTemplate>
                                                    <input type="checkbox" id="HeaderChkbox" onclick="javascript:checkall(this.id);" />
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="cbSelect" runat="server" />
                                                    <asp:Literal ID="ltlSoSelect" runat="server" Text='<%# Eval("SOID") %>' Visible="false" />
                                                  </ItemTemplate>
                                            </asp:TemplateField>

javascript:
function checkall(obj)
  {
    var chkbox = $get(obj);
    var rdAction = $(document.getElementById('<%=gridviewid.ClientID %>'));
    var list = rdAction.closest('table').find("INPUT[type='checkbox']");
    if(chkbox.checked)
    list.attr('checked', true);
    else
    list.attr('checked', false);
  }
 ASP.net Grid view
 <asp:TemplateField>
 <ItemTemplate>
  <asp:RadioButton ID="rblSelect" runat="server" GroupName="rb" onclick='<%# "javascript:SelectPartyRow(this.id," + Eval("PARTYID") + ")" %>' />
 <asp:Literal ID="ltlSeqNo" runat="server" Text='<%# Eval("PARTYID") %>' Visible="false"></asp:Literal>
 </ItemTemplate>
</asp:TemplateField>
  function SelectPartyRow(obj,value)
  {
 var rdAction = $(document.getElementById(obj));
    rdAction.closest('tr').addClass('SelectedGridRowStyle');
    rdAction.checked = true;
    // process all other radio buttons (excluding the the radio button Being checked).
    var list = rdAction.closest('table').find("INPUT[type='radio']").not(rdAction);
    list.attr('checked', false);
    list.closest('tr').removeClass('SelectedGridRowStyle');

  }

No comments:

Post a Comment