Width Issue when Displaying large data in ASP.Net GridView Cell

Last Reply on May 30, 2012 06:15 AM By Mudassar

Posted on May 30, 2012 05:48 AM

hi all I have one gridview with two columns.. Im fetching data which  is like invno, invno, invno, invno, invno, invno, invno, invno,.......... in one column.. but problem is when ifetch more data its Growing Across Gridview and Table.. i used following code

 

<td align="left" width="100%">
                <asp:GridView ID="GridView1" runat="server" Width="100%"
                    AutoGenerateColumns="False" BackColor="White" >
                <Columns>
 <asp:BoundField DataField="lblInvoice" HeaderText="Invoice(s)" />
            <asp:BoundField DataField="lblTotal" HeaderText="Total" />
           
                </Columns>
               
                </asp:GridView>

 

DataTable dt = new DataTable();

               dt.Columns.Add("lblInvoice", typeof(string));
               dt.Columns.Add("lblTotal", typeof(string));
                // dt.Columns.Add("Actions", typeof(LinkButton));
               DataRow dr = null;
               dr = dt.NewRow();
               dr["lblInvoice"] = newsInvoiceString;
               dr["lblTotal"] = "£" + total_amount.ToString();
               dt.Rows.Add(dr);
               //dt.Rows.Add(newsInvoiceString, "£" + total_amount.ToString());
               GridView1.DataSource = dt.DefaultView;
               GridView1.DataBind();

 

Posted on May 30, 2012 05:49 AM

Set the Width for the BoundField so that it does not stretch when large data is displayed

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html