如何为特定的列和标题指定特定的宽度 [英] How to specify specific width to specific column and heading

查看:105
本文介绍了如何为特定的列和标题指定特定的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为特定的列和标题指定特定的宽度
请告诉我我想指定任何地址或名称的FIX宽度
我应该使用哪个属性

How to specify specific width to specific column and heading
please tell me i want to specify FIX width of any address or name
which property i should use

<asp:GridView ID="grdsearch" runat="server" AutoGenerateColumns="False" 

                            onrowcreated="grdsearch_RowCreated"  

                            onrowdeleting="grdsearch_RowDeleting" DataKeyNames="cust_id" 

                            Width="750px">
                            <Columns>
                                <asp:BoundField DataField="cust_id" HeaderText="Customer Id" 

                                    ItemStyle-Width="200px"  ItemStyle-VerticalAlign="Middle" >
                            
                                <ItemStyle VerticalAlign="Middle" Width="200px" />
                            
                                </asp:BoundField>
                                <asp:BoundField DataField="cust_name" HeaderText="Customer Name" 

                                    ItemStyle-Width="200px"  ItemStyle-VerticalAlign="Middle" >
                               
                                <HeaderStyle Width="30%" />
                               
                                <ItemStyle VerticalAlign="Middle" Width="40%" />
                               
                                </asp:BoundField>
                                <asp:BoundField DataField="cust_address" HeaderText="Address"  

                                    ItemStyle-Width="200px"  ItemStyle-VerticalAlign="Middle" >
                               
                                <HeaderStyle Width="500px" />
                               
                                <ItemStyle VerticalAlign="Middle" Width="700px" Wrap="False" />
                               
                                </asp:BoundField>
                                <asp:BoundField DataField="cust_city" HeaderText="City" ItemStyle-Width="200px"  

                                    ItemStyle-VerticalAlign="Middle" >
                               
                                <ItemStyle VerticalAlign="Middle" Width="200px" />
                               
                                </asp:BoundField>
                                <asp:BoundField DataField="cust_telephone" HeaderText="Telephone"  

                                    ItemStyle-Width="200px"  ItemStyle-VerticalAlign="Middle" >
                              
                                <ItemStyle VerticalAlign="Middle" Width="200px" />
                              
                                </asp:BoundField>
                                <asp:BoundField DataField="cust_email" HeaderText="Email Id" />
                                <asp:BoundField DataField="sales_contact_prsn" 

                                    HeaderText="Sales Contact Person" />
                                <asp:BoundField DataField="sales_mob_no" HeaderText="Sales Mobile Number" />
                                  <asp:CommandField ShowDeleteButton="True" ButtonType="Button" 

                                    HeaderText="Delete" />
                            </Columns>
                          
                            <RowStyle Wrap="False" BorderWidth="10px" />
                          
                            <SelectedRowStyle CssClass="grdselectback" />
                        </asp:GridView>

推荐答案

使用以下模板,我们可以指定宽度;
或者,您可以为它们提供Css类以获取固定宽度.
Using Following Templates we can Specify Width;
or You can Provide Css Class to Them for Fix Width.
<FooterStyle Width="112px" />                                                                                    <HeaderStyle Width="112px" />                                                                                    <ItemStyle Width="112px" />


Kaushik


Kaushik




我遇到了类似的问题,并查看了GridView的定义,
如果我将您的gridview列的所有宽度相加,则它超出了网格的宽度.

汇总所有列宽后,请检查更改网格的宽度.

希望对您有所帮助.
Hi,

I had a similar problem and looking at the gridview defination,
If i sum all the widths if your gridview columns,it goes beyond the width of your grid.

Check changing the width of the grid after summing up all your column widths.

Hope this helps.


为每一列添加以下代码行,并指定每一列的宽度.
For each column add the below line of code and Specify each column Width.
ItemStyle-Width="5%" ItemStyle-Wrap="true"


确保所有列的宽度之和应等于GridView的宽度.

希望这对您有帮助...


Make sure that sum of all columns width should be equal to width of GridView.

Hope this will help you...


这篇关于如何为特定的列和标题指定特定的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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