1

こんにちは、グリッドを使用した購入レポートを作成しましたが、行数が少ない場合、つまり 1 行または 2 行の場合は、データ列をバインドせずにデフォルトの行を追加して、グリッドの見栄えを良くする必要があります。レポートを印刷するときに、この印刷ボタンとウィンドウの URL を表示したくないここに画像の説明を入力

そして、私はこのようなものを表示する必要があります

ここに画像の説明を入力

これは私の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") 

%>'>

String.Format("{0:f2}",DataBinder.Eval(Container.DataItem,"itdRate")) %>' >

                        <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")) %>' >

                        </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 = "";
                    }
                }


            }



        }

    }
4

2 に答える 2

0

グリッドビューに行がないときに何かしたい場合は、グリッドビューの EmptyDataTemplate を使用できます。
グリッドビューにデータがない場合、このテンプレートが表示されます。
テンプレートですので、お好きなデザインでお作りいただけます。この
例を次に示します。

スタック オーバーフローの例もあり


ます。gridview の下に何かを追加する場合は、フッター テンプレートを使用できます。
フッターテンプレートの良い例があります。http://www.ezylearning.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>

これにより、フッターの下に追加のスペースが作成されます。コードビハインドからも実行できます。データソースのレコード数を数え、フッターにテーブルを追加します。

于 2012-11-02T09:33:02.133 に答える
0

解決策を見つけました。なんて見逃せます。問題を解決するためにスタイルシートを使用できます。 CSS の min-height
プロパティを使用します。 ここにリンクがあります http://www.w3schools.com/cssref/pr_dim_min-height.asp

于 2012-11-08T07:26:18.067 に答える