Plz可以帮助我在Gridview Asp.Net中遇到问题 [英] Plz Can Help Me I Have Problem In My Gridview Asp.Net

查看:65
本文介绍了Plz可以帮助我在Gridview Asp.Net中遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有gridview工作正常但是当我添加新的长内容时宽度更大

我的gridview有源表单数据库



< br $>


i have gridview work good but when iam add new long content the width be larger
my gridview have source form database



<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:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Find" TypeName="Products"></asp:ObjectDataSource>







i想要帮助设定最大宽度





http://im37.gulfup。 com / nZEu0.png [ ^ ]

推荐答案

试试这样



创建模板字段对于描述
$ b $ c>项目模板中的
创建一个文本框用于描述并绑定它。

应用 CSS 文本框,使其看起来像标签。并为文本框应用工具提示,以便用户知道内部有冗长的文本 ..将其设为 readonly
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.


如果项目包含冗长的字符而没有超出列宽设置的空格,则会更改列宽。您需要应用样式来包装文本。



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");
                }
            }





另请参考:



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


这篇关于Plz可以帮助我在Gridview Asp.Net中遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆