Click here to Skip to main content
15,878,814 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have gridview work good but when iam add new long content the width be larger
my gridview have source form database



ASP.NET
<asp:GridView ID="gvProduct"   runat="server" BackColor="White"  BorderColor="#CCCCCC"  BorderStyle="None" BorderWidth="1px" CellPadding="3" ShowFooter="True"  Width="90%" AllowPaging="True" AllowSorting="True" DataSourceID="ObjectDataSource1" OnRowCommand="gvProduct_RowCommand" OnSelectedIndexChanged="gvProduct_SelectedIndexChanged" PageSize="5" CssClass="gvp" >
                        <Columns >
                            <asp:CommandField ShowSelectButton="True" />
                           
                        </Columns>
                        <FooterStyle BackColor="White" ForeColor="#000066" BorderStyle="Dashed" />
                        <HeaderStyle BackColor="#15A186" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                        <RowStyle ForeColor="#000066" />
                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#007DBB" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#00547E" />
                        
                     
                    </asp:GridView>


ASP.NET
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Find" TypeName="Products"></asp:ObjectDataSource>



i want help for set maximum width


http://im37.gulfup.com/nZEu0.png[^]
Posted
Updated 2-Feb-14 7:33am
v2
Comments
JoCodes 2-Feb-14 12:41pm    
Whats the issue or error you are facing?
ÂĦmâd Ŝâlâĥ 2-Feb-14 13:10pm    
when i and long string the format of div crop
JoCodes 2-Feb-14 13:12pm    
Can you please explain that?Long string?
ÂĦmâd Ŝâlâĥ 2-Feb-14 13:32pm    
http://im37.gulfup.com/nZEu0.png

thats it
JoCodes 2-Feb-14 13:33pm    
Not able to view it

Try like this

Create a template field for the Description column
in the Item Template create a text box for the Description and bind it.
Apply CSS to the Textbox such that it will look like label. and apply tooltip for the textbox so that the users will come to know that there is a lengthy text inside.. Make it as readonly.
 
Share this answer
 
The Column width will be changed if the item contains lengthy characters without space that exceeds the Column width set.You need to apply style for Wrapping the text.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Cells[1].Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
                }
            }


Also reference :

http://perishablepress.com/wrapping-content/[^]
 
Share this answer
 

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