开发者

setting maximum length in a gridview

Greetings Everyone..i just wanna ask is it possible to set a maximum length in my field in gridview?

Below is my g开发者_运维技巧ridview sample that retrieve a formatted html in my database..All i want to achieve is to limit the maximum length of characters i.e "50" then automatically create a pagination for the succeeding characters..to be posted in the gridview

 <div id="GridScroll" class="grid_scroll">
            <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BorderStyle="None" 
        GridLines="None"
    DataSourceID="SqlDataSource1" Height="308px" Width="1174px" ShowHeader="False">
    <Columns>
        <asp:TemplateField SortExpression="NewsText" ShowHeader="False">
            <ItemTemplate>
                <asp:Literal EnableViewState="false" ID="literal1" Text='<%# Bind("NewsText") %>' mode="PassThrough" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Any advise or suggestion is highly sought...thank you


use this in the test property of literal

Text='<%# Bind("NewsText").ToString().Substring(0, 50) %>'


try to set fixed width on asp:Literal object

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜