Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi my friends
i have a tab TabContainer from ToolkitScriptManager.
then i have two tabpanel, in Each tabpanel have a two gridview.
gridview1 and gridview1

i want print from gridview .how opt gridview in tab then print

how to print from active tab
ASP.NET
<asp:Content ID="Content2" ContentPlaceHolderID="BodyPageHolder" runat="Server">
    <script type="text/javascript">
        function doPrint() {


            var tab = document.getElementById('<%= T.ClientID %>');
                    var prtContent = document.getElementById('<%= GridView1.ClientID %>');
            prtContent.border = 0; //set no border here

            var WinPrint = window.open('', '', 'letf=100,top=100,width=1000,height=1000, toolbar=0,scrollbars=1,status=0,resizable=1');
            WinPrint.document.write(prtContent.outerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            WinPrint.close();
        }
    
    </script>
    <script type="text/javascript">
        Sys.require(Sys.components.tabContainer, function () {
            var container = Sys.create.tabContainer("#tabcontainer", 0);
            $("#tab1_body").tabPanel(container, "#tab1");
            $("#tab2_body").tabPanel(container, "#tab2");

        });  
    </script>
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <br />
    <table align="center" cellpadding="0" cellspacing="0" style="background-color: #E9D3BE; box-shadow: 0Px 0PX 7Px 5px; border-radius: 6px 6px 6px 6px;
        width: 747px; height: 420px;">
        <tr>
            <td style="text-align: center; padding: 0px 0px 0px 0px; background-color: #FFFFFF;">
                <div class="FormTableDivTitle">
                    <asp:Label ID="Label4" runat="server" Text="مشاهده تمامی پستهای سازمانی " CssClass="FormTableDivTitleMessage"></asp:Label>
                </div>
            </td>
        </tr>
        <tr>
            <td align="center">
                <%--     <div  >
                    <div dir="rtl" style="text-align: center">  --%>
                <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Style="background-color: E9D3BE" align="right" Height="405px"
                    Width="654px" ClientIDMode="AutoID" BorderColor="#663300" BorderWidth="1px">
                    <cc1:TabPanel ID="TabPanel1"  runat="server" HeaderText="لیست پست های سازمانی به همراه افراد">
                        <ContentTemplate>
                            <div style="height: 400px; width: auto; overflow: auto; text-align: right;" dir="ltr">
                                <asp:UpdatePanel ID="UpdatePanelCommandper" runat="server">
                                    <ContentTemplate>
                                        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BorderWidth="1px"
                                            CellPadding="1" CssClass="GridViewStyle" DataSourceID="SqlDataSource1" Font-Names="Tahoma" Font-Size="11px" GridLines="Vertical"
                                            Height="47px" HorizontalAlign="Center" PageSize="400" Width="600px">
                                            <AlternatingRowStyle CssClass="AltRowStyle" />
                                            <Columns>
                                                <asp:BoundField DataField="FOrgChartParentID" HeaderText="FOrgChartParentID" SortExpression="FOrgChartParentID" Visible="False" />
                                                <asp:BoundField DataField="FOrgChartClass" HeaderText="FOrgChartClass" SortExpression="FOrgChartClass" Visible="False"></asp:BoundField>
                                                <asp:BoundField DataField="FOrgChartID" HeaderText="FOrgChartID" SortExpression="FOrgChartID" Visible="False"></asp:BoundField>
                                                <asp:BoundField DataField="CountPostCommon" HeaderText="تعداد" ReadOnly="True" SortExpression="CountPostCommon">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="NamePostCommon" HeaderText="دارندگان پست سازمانی" ReadOnly="True" SortExpression="NamePostCommon">
                                                    <ItemStyle HorizontalAlign="Right" Wrap="True" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="ParentName" HeaderText="زیر بخش" SortExpression="ParentName">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="FOrgChartName" HeaderText="پست سازمانی" SortExpression="FOrgChartName">
                                                    <ItemStyle HorizontalAlign="Center" Width="120px" Wrap="False" />
                                                </asp:BoundField>
                                                <asp:TemplateField HeaderText="ردیف">
                                                    <ItemTemplate>
                                                        <%#MSLibrary.Persian.PersianNumber.ToPersianNumbers(Container.DataItemIndex + 1)%>
                                                    </ItemTemplate>
                                                    <ItemStyle BorderStyle="None" HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                            </Columns>
                                            <HeaderStyle BorderStyle="Inset" BorderWidth="0px" CssClass="HeaderStyle" Font-Names="Tahoma" Font-Size="10px" Font-Underline="False"
                                                HorizontalAlign="Center" Wrap="False" />
                                            <PagerStyle BackColor="White" CssClass="PagerStyle" ForeColor="#000066" HorizontalAlign="Center" />
                                            <RowStyle CssClass="RowStyle" ForeColor="#000066" />
                                            <SelectedRowStyle BackColor="#669999" CssClass="SelectedRowStyle" Font-Bold="True" ForeColor="White" />
                                        </asp:GridView>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel ID="TabPanel2"  runat="server" HeaderText="لیست پست های سازمانی">
                        <ContentTemplate>
                            <div style="height: 400px; width: auto; overflow: auto; text-align: right;" dir="ltr">
                                <asp:UpdatePanel ID="updatepListshowpost" runat="server">
                                    <ContentTemplate>
                                        <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BorderWidth="1px"
                                            CellPadding="1" CssClass="GridViewStyle" DataKeyNames="FOrgChartID" DataSourceID="SqlDataSource1" Font-Names="Tahoma"
                                            Font-Size="11px" GridLines="Vertical" Height="47px" HorizontalAlign="Center" PageSize="400" Width="600px">
                                            <AlternatingRowStyle CssClass="AltRowStyle" />
                                            <Columns>
                                                <asp:TemplateField HeaderText="لیست افراد" Visible="False">
                                                    <ItemTemplate>
                                                        <%--<a href='ShowInfoUser.aspx?id=<%#Eval("FUserID") %>'   Text ='<%# ShowNamefamily() %>'   rel="[facebox]" rev="iframe|300|400"   /> --%>
                                                        <%--      <asp:HyperLink ID="Familname" Font-Underline=false  runat="server"  Text ='<%# ShowNamefamily() %>'  rel="[facebox]" rev="iframe|300|400"  NavigateUrl=<%# String.Format("javascript:OpenPopupModal('ShowInfoUser.aspx?id={0}','190px','20px','610px','925px')", Eval("FUserID")) %>/> --%>
                                                        <asp:HyperLink ID="Familname" runat="server" Font-Underline="false" NavigateUrl='<%# String.Format("ListUsersOfAnOrgPost.aspx?id={0}&Orgchart={1} ", Eval("FOrgChartID"),Eval("FOrgChartName")) %>'
                                                            rel="[facebox]" rev="iframe|300|400" Text="مشاهده" />
                                                    </ItemTemplate>
                                                    <ItemStyle Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="جايگاه" SortExpression="FOrgChartClass">
                                                    <ItemTemplate>
                                                        <asp:Label ID="Label5" runat="server" Text="<%#GetPostClassName() %>"></asp:Label>
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                </asp:TemplateField>
                                                <asp:BoundField DataField="FOrgChartID" HeaderText="FOrgChartID" InsertVisible="False" SortExpression="FOrgChartID" Visible="False" />
                                                <asp:BoundField DataField="FOrgChartClass" HeaderText="FOrgChartClass" SortExpression="FOrgChartClass" Visible="False" />
                                                <asp:BoundField DataField="FOrgChartParentID" HeaderText="FOrgChartParentID" SortExpression="FOrgChartParentID" Visible="False" />
                                                <asp:BoundField DataField="ParentName" HeaderText="پست سازمانی مافوق" SortExpression="ParentName">
                                                    <ItemStyle HorizontalAlign="Center" Wrap="False" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="FOrgChartName" HeaderText="عنوان پست سازمانی" SortExpression="FOrgChartName">
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                    <ItemStyle HorizontalAlign="Center" Wrap="False" />
                                                </asp:BoundField>
                                                <asp:TemplateField HeaderText="ردیف">
                                                    <ItemTemplate>
                                                        <%#MSLibrary.Persian.PersianNumber.ToPersianNumbers(Container.DataItemIndex + 1)%>
                                                    </ItemTemplate>
                                                    <ItemStyle BorderStyle="None" HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                            </Columns>
                                            <HeaderStyle BorderStyle="Inset" BorderWidth="0px" CssClass="HeaderStyle" Font-Names="Tahoma" Font-Size="10px" Font-Underline="False"
                                                HorizontalAlign="Center" Wrap="False" />
                                            <PagerStyle BackColor="White" CssClass="PagerStyle" ForeColor="#000066" HorizontalAlign="Center" />
                                            <RowStyle CssClass="RowStyle" ForeColor="#000066" />
                                            <SelectedRowStyle BackColor="#669999" CssClass="SelectedRowStyle" Font-Bold="True" ForeColor="White" />
                                        </asp:GridView>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </ContentTemplate>
                    </cc1:TabPanel>
                </asp:TabContainer>
                <%-- </div>  
                   </div>--%>
                <br />
                <div style="text-align: center">
                    <input type="button" value="چاب اطلاعات جدول"  önclick="doPrint();" id="BPrint" class="FormTableButton" style="height: 24px">
                </div>
                <br />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ICTPortalDBConnectionString %>"
                    SelectCommand="SELECT * FROM [VDB_OrgPostName]"></asp:SqlDataSource>
            </td>
        </tr>
    </table>
    <br />
</asp:Content>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900