如何在asp.net的gridview中设置模板字段的宽度 [英] how to set width for templatefields in gridview in asp.net

查看:65
本文介绍了如何在asp.net的gridview中设置模板字段的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有

我想为gridview中的每个TemplateField设置宽度
可能吗 ?如果是,请还原
其他
请告诉我其他相同的解决方案.

谢谢..................

Dear all

I want to width for every TemplateField in gridview
Is it possible ? If yes please revert
else
please tell me other solution for the same.

thanks..................

推荐答案

要设置GridView的列宽,可以使用< HeaderStyle>或< ItemStyle>为模板列设置witdth.

样本:
To set the column width for GridView, you can use the <HeaderStyle> or <ItemStyle> to set witdth for a template column.

Sample:
<asp:TemplateField HeaderText="used" SortExpression="used">
<HeaderStyle Width="100" />
<ItemStyle Width="100" />

<HeaderTemplate>
fjsfjkldsfksdjfdsfjfkksfsdkfdsjfjkfdsj
</HeaderTemplate>

<EditItemTemplate>
......
......



此处的详细信息: MSDN:教程12:在GridView控件中使用TemplateFields [



Details here: MSDN: Tutorial 12: Using TemplateFields in the GridView Control[^]


使用ItemStyle-Width(ItemStyle-*)
use ItemStyle-Width (ItemStyle-*)


以这种方式尝试.

try in this way.

<asp:TemplateField HeaderText="Name">
    <ItemTemplate>
           <asp:Label ID="lblCatId" runat="server" Text='<%#Eval("CatId") %>'></asp:Label>
    </ItemTemplate>
    <ItemStyle Width="20%" />
   </asp:TemplateField>


这篇关于如何在asp.net的gridview中设置模板字段的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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