在asp.net中打印报告

时间:2012-11-02 07:05:15

标签: asp.net css

您好我已经建立在我所使用的栅格,但在情况下,当没有行的较少即,在一行或两行的情况下,我必须添加deafult行而不以便网格看起来结合datacolumns购买报告更好,当我打印报告我不想显示此打印按钮和网址 我的窗口enter image description here

我必须展示一些像这样的东西

enter image description here

这是我的aspx代码

<table style="width:100%;">
        <tr>
          <td class="style1">
            <div class="cmpnylogo">
            <!--<img id="imglogo" runat="server"/>-->
                <table style="width:100%;">
                    <tr>
                        <td class="style69">
                            &nbsp;</td>
                                <td>
                                <div>

                                    <table style="width:100%;">
                                        <tr>
                                            <td class="style61">
                                    <asp:Label ID="Label20" runat="server" Text="Office"></asp:Label>
                                            </td>
                                            <td>
                                    <asp:Label ID="lbloffice" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style61">
                                    <asp:Label ID="Label21" runat="server" Text="Works"></asp:Label>
                                            </td>
                                            <td>
                                    <asp:Label ID="lblworks" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style61">
                                    <asp:Label ID="Label22" runat="server" Text="Phone"></asp:Label>
                                            </td>
                                            <td>
                                    <asp:Label ID="lblphone" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style61">
                                    <asp:Label ID="lblemail" runat="server" Text="Email"></asp:Label>
                                            </td>
                                            <td>
                                    <asp:Label ID="lblmail" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>

                                </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="style58" colspan="2">
                                <hr />
                                </td>
                            </tr>
                        </table>
            </div>
          </td>

        </tr>
        <tr>
            <td align="center" class="style1">
                <div class="dvtitle">
                <div class="title">Purchase Order</div>

                </div>
             </td>
        </tr>
        <tr>
            <td align="center" class="style1">
                <table style="width:100%;border-left-style:none;border-right-style:none;" border="1px">
                    <tr>
                        <td class="style64" valign="top">
                            <table style="width:100%;">
                                <tr>
                                    <td class="style70">
                                        <div class="dvitems">
                                            Kind attn:-
                                        </div>
                                    </td>
                                    <td align="left">
                                  <asp:Label ID="lblattn" runat="server" Text="Label"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style70">
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td class="style70">
                                        &nbsp;</td>
                                    <td align="left">
                                        <asp:Label ID="lblpartyadd" runat="server" Text="Label"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="style63" valign="top">
                            <table style="width:117%; height: 126px;">
                                <tr>
                                    <td class="style68">
                           <div class="dvpo">Consignee
                           </div>
                                        </td>
                                        <td align="left">
                           <asp:Label ID="lblconsignee" runat="server"> 
                           </asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="style68">
                                            <div>
                                                Name</div>
                                        </td>
                                        <td align="left">
                                        <asp:Label ID="lblconname" runat="server" Text="Label"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="style68">
                                            <div>
                                                Address</div>
                                        </td>
                                        <td align="left">
                                            <asp:Label ID="lblconadd" runat="server" Text="Label"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="style68">
                                            <div>
                                                City</div>
                                        </td>
                                        <td align="left">
                                            <asp:Label ID="lblconcity" runat="server" Text="Label"></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td class="style68">
                                            <div>
                                                TINNO.</div>
                                        </td>
                                        <td align="left">
                                        <asp:Label ID="lblcontinno" runat="server" Text="Label"></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td class="style68">
                                            <div>
                                                ECC NO</div>
                                        </td>
                                        <td align="left">
                                          <asp:Label ID="lblconeccno" runat="server" Text="Label"></asp:Label></td>
                                    </tr>
                                </table>
                            </td>
                        <td valign="top" align="left">

                            <table style="width:100%;">
                                <tr>
                                    <td class="style67">
                                        <div class="dvpo">
                                            PoNo:</div>
                                    </td>
                                    <td>
                                        <asp:Label ID="lblpono" runat="server" Text="Label"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="style67">
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td class="style67">
                                        <div class="dvpo">
                                            Date:</div>
                                    </td>
                                    <td>
                                        <asp:Label ID="lbldate" runat="server" Text="Label"></asp:Label>
                                    </td>
                                </tr>
                            </table>

                        </td>
                    </tr>
                    </table>
             </td>
        </tr>
        <tr>
           <td>
            <div class="dvright">

            </div>
           </td>
        </tr>
        <tr>
            <td class="style2">

                                    <div class="dvitems">Dear Sir/Mam,</div>
                                    </td>

        </tr>
        <tr>
            <td class="style2">

            <div class="dvinstruction">
 We are Pleased to order the under mentioned item kindly make the arrangements for the dispatch of same

             </div>
            </td>

        </tr>
        <tr>
            <td class="style2">



            </td>
        </tr>
        <tr>
            <td>
             <table>
                    <tr>
                    <td>
  <div style="width:100%; overflow:auto;min-height:500px;">                                             
  <asp:GridView ID="GridView1" runat="server" width:auto Height:auto AutoGenerateColumns="False" ShowFooter="True" style="min-width:700px"
  onrowdatabound="GridView1_RowDataBound">

                         <Columns>
                        <asp:BoundField DataField="itdsrno" HeaderText="Srno" />
                        <asp:BoundField DataField="itemname" HeaderText="Item" />
                        <asp:BoundField DataField="itdlength" HeaderText="Gsm" />
                        <asp:TemplateField HeaderText="Qty">
                        <FooterTemplate>
                        <asp:Label ID="lbltotalquan" runat="server" Text="Label"></asp:Label>
                         </FooterTemplate>
                         <ItemTemplate>
                            <asp:Label ID="lblquantity" runat="server" Text='<%# Eval("itdquan") 

%GT;'&GT;                                                                                                                                                                                                                                                                                                                                

String.Format(“{0:f2}”,DataBinder.Eval(Container.DataItem,“itdRate”))%&gt;' &GT;                                                              

                        <asp:TemplateField HeaderText="Amount">
                            <FooterTemplate>
                                <asp:Label ID="lbltxttotal" runat="server"  />
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblamount" runat="server" Text='<%# 

String.Format(“{0:f2}”,DataBinder.Eval(Container.DataItem,“itdAmou”))%&gt;' &GT;                                 

                        </asp:TemplateField>

                        <asp:BoundField DataField="itdrema" HeaderText="Remark" />
                    </Columns>

                </asp:GridView>
</div>


                        </td>
                    </tr>
                 </table>

            </td>
        </tr>
    </table>

和cs代码是

 if (!IsPostBack)
    {
        int compcode=0;
        c.GetConection();
        if(Session["compcode"]!=null)
        {
        compcode=Convert.ToInt32(Session["compcode"]);
        DataTable dtcomp = new DataTable();
        da = new SqlDataAdapter();
        SqlCommand cmdcom = new SqlCommand("sp_Getcompanyinfobycode",c.con);
        cmdcom.CommandType = CommandType.StoredProcedure;
        cmdcom.Connection = c.con;
        cmdcom.Parameters.AddWithValue("@compcode", compcode);
        da.SelectCommand = cmdcom;
        da.Fill(dtcomp);
        if (dtcomp.Rows.Count > 0)
        {
            if (dtcomp.Rows[0]["compadd1"] != null)
            {
                if (!string.IsNullOrEmpty(dtcomp.Rows[0]["compadd1"].ToString()))
                {

                    lbloffice.Text= dtcomp.Rows[0]["compadd1"].ToString();
                }
                else
                {
                    lbloffice.Text = "";
                }
                if (!string.IsNullOrEmpty(dtcomp.Rows[0]["compphor"].ToString()))
                {

                    lblphone.Text = dtcomp.Rows[0]["compphor"].ToString();
                }
                else
                {
                    lblphone.Text = "";
                }

            }
        }




        }



        System.Data.DataTable dt=new DataTable();
        da = new SqlDataAdapter("select convert(int,itdquan) as itdquan,convert(int,itdlength) as itdlength, * from tmpMateIn", c.con);
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {

            //if (dt.Rows.Count < 5)
            //{
            //    dt.Rows.Add(new object[] { "", "" });

            //}
            GridView1.DataSource = dt;

            GridView1.DataBind();



        }
        if (dt.Rows.Count > 0)
        {


            if (dt.Rows[0]["mstdate"] != null)
            {
                lbldeliverydt.Text = string.Format("{0:dd-MM-yyyy}", dt.Rows[0]["mstdate"]);
            }
            else
            {
                lbldeliverydt.Text = "";
            }
            if ((dt.Rows[0]["mstdeliDes"])!=null)
            {
                lblcity.Text = dt.Rows[0]["mstdeliDes"].ToString();
            }
            else
            {
                lblcity.Text = "";
            }
            if ((dt.Rows[0]["mstfrghtper"] != null))
            {
                if (!string.IsNullOrEmpty(dt.Rows[0]["mstfrghtper"].ToString()))
                {
                    decimal mstfrght = Convert.ToDecimal(dt.Rows[0]["mstfrghtper"].ToString());
                    lbldiscbill.Text = String.Format("{0:f2}", mstfrght);
                }
            }
            else
            {
                lbldiscbill.Text = "";
            }
            if ((dt.Rows[0]["msttaxper"] != null))
            {
                if (!string.IsNullOrEmpty(dt.Rows[0]["msttaxper"].ToString()))
                {
                    decimal msttaxper = Convert.ToDecimal(dt.Rows[0]["msttaxper"].ToString());

                    lbltax.Text = String.Format("{0:f2}", msttaxper);
                }
            }
            else
            {
                lbltax.Text = "";
            }
            if ((dt.Rows[0]["mstpayDes"] != null))
            {
                lblpterm.Text = dt.Rows[0]["mstpayDes"].ToString();
            }
            else
            {
                lblpterm.Text = "";
            }
            if ((dt.Rows[0]["itdrefq"] != null))
            {
                if (!string.IsNullOrEmpty(dt.Rows[0]["itdrefq"].ToString()))
                {
                    decimal itdrefq = Convert.ToDecimal(dt.Rows[0]["itdrefq"].ToString());
                    lblvattinno.Text = String.Format("{0:f2}", itdrefq);
                }
            }
            else
            {
                lblvattinno.Text = "";
            }

            da = new SqlDataAdapter();
            DataTable dtmtdetail = new DataTable();
            SqlCommand cmd = new SqlCommand("sp_Getordemstdetailbycode", c.con);
            cmd.Parameters.AddWithValue("@mstcode", dt.Rows[0]["mstcode"]);
            cmd.Parameters.AddWithValue("@compcode", dt.Rows[0]["compcode"]);
            cmd.Parameters.AddWithValue("@msttype", dt.Rows[0]["msttype"]);
            cmd.CommandType = CommandType.StoredProcedure;
            da.SelectCommand = cmd;
            da.Fill(dtmtdetail);
            if (dtmtdetail.Rows.Count > 0)
            {
                if ((dtmtdetail.Rows[0]["mstindno"] != null))
                {
                    if (!string.IsNullOrEmpty(dtmtdetail.Rows[0]["mstindno"].ToString()))
                    {
                        decimal mstindno = Convert.ToDecimal(dtmtdetail.Rows[0]["mstindno"].ToString());
                        lblcsttinno.Text = string.Format("{0:f2}", mstindno);
                    }
                }
                else
                {
                    lblcsttinno.Text = "";
                }
                if ((dtmtdetail.Rows[0]["mstsection"] != null))
                {
                    if (!string.IsNullOrEmpty(dtmtdetail.Rows[0]["mstsection"].ToString()))
                    {
                        lbleccno.Text = string.Format("{0:f2}", dtmtdetail.Rows[0]["mstsection"].ToString());
                    }
                }
                else
                {
                    lbleccno.Text = "";
                }





            }

            da = new SqlDataAdapter();
            DataTable dtpartyinfo = new DataTable();
            SqlCommand cmd1 = new SqlCommand("sp_GetAccountinfo", c.con);
            cmd1.Parameters.AddWithValue("@acctname", dt.Rows[0]["acctname"]);
            cmd1.CommandType = CommandType.StoredProcedure;
            da.SelectCommand = cmd1;
            da.Fill(dtpartyinfo);
            if (dtpartyinfo.Rows.Count > 0)
            {

                if (dt.Rows[0]["acctaddr"] != null)
                {
                    if (!string.IsNullOrEmpty(dtpartyinfo.Rows[0]["acctaddr"].ToString()))
                    {

                        lblpartyadd.Text = dtpartyinfo.Rows[0]["acctaddr"].ToString();
                    }
                    else
                    {
                        lblpartyadd.Text = "";
                    }
                }


            }






            lblpono.Text = dt.Rows[0]["compcode"].ToString();
            if (dt.Rows[0]["mstdate"] != null)
            {

                lbldate.Text = String.Format("{0:dd-MM-yyyy}", dt.Rows[0]["mstdate"]);
            }
            else
            {
                lbldate.Text = "";
            }
            lblconsignee.Text = dt.Rows[0]["mstdepa"].ToString();
            lblattn.Text = dt.Rows[0]["acctname"].ToString();
            if (dt.Rows[0]["acctname"] != null)
            {
                lblcompany.Text = "For " + dt.Rows[0]["acctname"].ToString();
            }
            imglogo.Attributes.Add("src", "/office%20pro/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_86d5effd-30fa-48d6-9a87-49b5ae9a616a.png");
            da = new SqlDataAdapter();
            DataTable dtconsigneeinfo = new DataTable();
            SqlCommand cmd2 = new SqlCommand("sp_GetAccountinfo", c.con);
            cmd2.Parameters.AddWithValue("@acctname", dt.Rows[0]["mstdepa"]);
            cmd2.CommandType = CommandType.StoredProcedure;
            da.SelectCommand = cmd2;
            da.Fill(dtconsigneeinfo);
            if (dtconsigneeinfo.Rows.Count > 0)
            {
                if (dtconsigneeinfo.Rows[0]["acctphon"] != null)
                {
                    if (!string.IsNullOrEmpty(dtconsigneeinfo.Rows[0]["acctphon"].ToString()))
                    {

                        lblphone.Text = dtconsigneeinfo.Rows[0]["acctphon"].ToString();
                    }
                    else
                    {
                        lblphone.Text = "";
                    }
                }
                if (dtconsigneeinfo.Rows[0]["acctaddr"] != null)
                {
                    if (!string.IsNullOrEmpty(dtconsigneeinfo.Rows[0]["acctaddr"].ToString()))
                    {

                        lbloffice.Text = dtconsigneeinfo.Rows[0]["acctaddr"].ToString();
                    }
                    else
                    {
                        lbloffice.Text = "";
                    }
                }


            }



        }

    }

2 个答案:

答案 0 :(得分:0)

如果你想在gridview中没有行的情况下那么你可以使用gridview的EmptyDataTemplate。
当gridview中没有数据时,会显示此模板 由于它是一个模板,因此您可以根据您的选择进行设计 以下是this

的示例

还有一个stack overflow

的例子 如果你想在gridview下面添加一些东西你可以使用页脚模板。
有一个很好的页脚模板示例。 http://www.ezzylearning.com/tutorial.aspx?tid=1676759
由于它是一个模板,你可以在里面使用html或服务器控件。


<FooterTemplate>
   <asp:Label ID="lbltotalquan" runat="server" Text="Label"></asp:Label>
 <table>
     <tr>
         <td style='height:50px;'></td>
     <tr/>
 </table>
 </FooterTemplate>

这会在页脚下方创建额外的空间。它也可以从代码背后完成。 计算数据库中的记录数,并在页脚中添加表。

答案 1 :(得分:0)

我找到了解决方案。我多么想念它。您可以使用样式表来解决问题。
使用CSS的 min-height 属性。
这是一个链接
http://www.w3schools.com/cssref/pr_dim_min-height.asp