I need some help trying to get a popup window to display the details of the selected checkboxes in a gridview control. I found a site that had some sample code and I got the checkall checkboxes part to work but I can't get the popup window to work. Here is a link to the sample: http://sharepointgroup.wordpress.com...n-popupwindow/. Could someone take look at my code and see where i might be going wrong. Basically I have it where if I hit the "Print Selected Rows" Button nothing happens.
Here is my html code for certificates.aspx:
Code:<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script> function SelectAllCheckboxes(spanChk) { // Added as ASPX uses SPAN for checkbox var oItem = spanChk.children; var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0]; xState = theBox.checked; elm = theBox.form.elements; for (i = 0; i < elm.length; i++) if (elm[i].type == "checkbox" && elm[i].id != theBox.id) { //elm[i].click(); if (elm[i].checked != xState) elm[i].click(); //elm[i].checked=xState; } } </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> //Print Checkbox to print.aspx (function () { $("button.print2").hide(); // hide the print button // set the postback function for checkall checkbox // html control must set to “chkAll” css class $("input:checkbox.chkAll").click(function () { xState = $("input:checkbox.chkAll").is(':checked'); $("input:checkbox.print2").each(function () { $(this).attr("checked", xState); }); if (xState) $("button.print2").show(); else $("button.print2").hide(); }); // set the postback function for checkboxes // html control must set to “print2″ css class $("input:checkbox.print2").click(function () { var count = $(":checked.print2").length; if (count == 0) { $("button.print2").hide(); } else { $("button.print2").show(); } }); // set the postback function for print button // html control must set to “print2″ css class $("button.print2").click(function () { var idList = "count=" + $(":checked.print2").length; var count = 0; $(":checked.print2").each(function () { idList = idList + "&id" + count + "=" + $(this).val() count++; }); window.open('print.aspx?' + idList); return false; }); })(); </script> </head> <body> <form id="form1" runat="server"> <div> <asp:LoginStatus ID="LoginStatus1" runat="server" /> <br /> <br /> <br /> <button id="print2" visible="False"> Print Selected Rows</button> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CertificateID" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."> <Columns> <asp:TemplateField ShowHeader="true"> <HeaderTemplate> <input id="chkAll" onclick="javascript: SelectAllCheckboxes(this);" runat="server" type="checkbox" class="chkAll"/> </HeaderTemplate> <ItemTemplate> <input type="checkbox" value='<%#Eval("CertificateID").ToString()%>' class="print2" id="chkSelect" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="CertificateID" HeaderText="CertificateID" InsertVisible="False" ReadOnly="True" SortExpression="CertificateID" /> <asp:BoundField DataField="Customs_Entry" HeaderText="Customs_Entry" SortExpression="Customs_Entry" /> <asp:BoundField DataField="Date_Certificate" HeaderText="Date_Certificate" SortExpression="Date_Certificate" /> <asp:BoundField DataField="Invoice_Number" HeaderText="Invoice_Number" SortExpression="Invoice_Number" /> <asp:BoundField DataField="Product_Number" HeaderText="Product_Number" SortExpression="Product_Number" /> <asp:BoundField DataField="Product_Name" HeaderText="Product_Name" SortExpression="Product_Name" /> <asp:BoundField DataField="Product_Category" HeaderText="Product_Category" SortExpression="Product_Category" /> <asp:BoundField DataField="CPSC_Regulation" HeaderText="CPSC_Regulation" SortExpression="CPSC_Regulation" /> <asp:BoundField DataField="Date_Manufactured" HeaderText="Date_Manufactured" SortExpression="Date_Manufactured" /> <asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer" SortExpression="Manufacturer" /> <asp:BoundField DataField="Date_Tested" HeaderText="Date_Tested" SortExpression="Date_Tested" /> <asp:BoundField DataField="Test_Lot_ID" HeaderText="Test_Lot_ID" SortExpression="Test_Lot_ID" /> <asp:BoundField DataField="Name_Laboratory" HeaderText="Name_Laboratory" SortExpression="Name_Laboratory" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>" DeleteCommand="DELETE FROM [Certificate] WHERE [CertificateID] = @CertificateID" InsertCommand="INSERT INTO [Certificate] ([Customs_Entry], [Date_Certificate], [Invoice_Number], [Product_Number], [Product_Name], [Product_Category], [CPSC_Regulation], [Date_Manufactured], [Manufacturer], [Date_Tested], [Test_Lot_ID], [Name_Laboratory]) VALUES (@Customs_Entry, @Date_Certificate, @Invoice_Number, @Product_Number, @Product_Name, @Product_Category, @CPSC_Regulation, @Date_Manufactured, @Manufacturer, @Date_Tested, @Test_Lot_ID, @Name_Laboratory)" ProviderName="<%$ ConnectionStrings:LocalSqlServer.ProviderName %>" SelectCommand="SELECT [CertificateID], [Customs_Entry], [Date_Certificate], [Invoice_Number], [Product_Number], [Product_Name], [Product_Category], [CPSC_Regulation], [Date_Manufactured], [Manufacturer], [Date_Tested], [Test_Lot_ID], [Name_Laboratory] FROM [Certificate]" UpdateCommand="UPDATE [Certificate] SET [Customs_Entry] = @Customs_Entry, [Date_Certificate] = @Date_Certificate, [Invoice_Number] = @Invoice_Number, [Product_Number] = @Product_Number, [Product_Name] = @Product_Name, [Product_Category] = @Product_Category, [CPSC_Regulation] = @CPSC_Regulation, [Date_Manufactured] = @Date_Manufactured, [Manufacturer] = @Manufacturer, [Date_Tested] = @Date_Tested, [Test_Lot_ID] = @Test_Lot_ID, [Name_Laboratory] = @Name_Laboratory WHERE [CertificateID] = @CertificateID"> <DeleteParameters> <asp:Parameter Name="CertificateID" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="Customs_Entry" Type="String" /> <asp:Parameter Name="Date_Certificate" Type="String" /> <asp:Parameter Name="Invoice_Number" Type="String" /> <asp:Parameter Name="Product_Number" Type="String" /> <asp:Parameter Name="Product_Name" Type="String" /> <asp:Parameter Name="Product_Category" Type="String" /> <asp:Parameter Name="CPSC_Regulation" Type="String" /> <asp:Parameter Name="Date_Manufactured" Type="String" /> <asp:Parameter Name="Manufacturer" Type="String" /> <asp:Parameter Name="Date_Tested" Type="String" /> <asp:Parameter Name="Test_Lot_ID" Type="String" /> <asp:Parameter Name="Name_Laboratory" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="Customs_Entry" Type="String" /> <asp:Parameter Name="Date_Certificate" Type="String" /> <asp:Parameter Name="Invoice_Number" Type="String" /> <asp:Parameter Name="Product_Number" Type="String" /> <asp:Parameter Name="Product_Name" Type="String" /> <asp:Parameter Name="Product_Category" Type="String" /> <asp:Parameter Name="CPSC_Regulation" Type="String" /> <asp:Parameter Name="Date_Manufactured" Type="String" /> <asp:Parameter Name="Manufacturer" Type="String" /> <asp:Parameter Name="Date_Tested" Type="String" /> <asp:Parameter Name="Test_Lot_ID" Type="String" /> <asp:Parameter Name="Name_Laboratory" Type="String" /> <asp:Parameter Name="CertificateID" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource> <br /> <br /> <br /> <br /> </div> </form> </body> </html>
Here is my vb code for certificates.aspx:
Here is my code for Print.aspx:Code:Imports System.Text Public Class WebForm4 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged 'Check All Checkboxes Code: ' StringBuilder object Dim str As New StringBuilder() ' Select the checkboxes from the GridView control For i As Integer = 0 To GridView1.Rows.Count - 1 Dim row As GridViewRow = GridView1.Rows(i) Dim isChecked As Boolean = DirectCast(row.FindControl("chkSelect"), CheckBox).Checked If isChecked Then ' Column 2 is the name column str.Append(GridView1.Rows(i).Cells(2).Text) End If Next ' prints out the result Response.Write(str.ToString()) End Sub End Class
Code:Public Class WebForm6 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim pageCount As Integer = 1 Dim Count As Integer = Convert.ToInt32(Request.Params(0).ToString()) Dim IDList As New List(Of Integer)() For i As Integer = 0 To Count - 1 Dim ID As String = Request.Params("id" & i.ToString()).ToString() IDList.Add(Convert.ToInt32(ID)) Next End If End Sub End Class


Reply With Quote
Bookmarks