Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my Grideview2 I wanted to increase the width of datafield column 'reg_date':
I tried using the following code but not working out. Can anyone help me out.

XML
<asp:GridView ID="GridView2" runat="server"  HorizontalAlign="Center"  AutoGenerateColumns="False"
               style="border-color: #808000; top: 298px; left: 515px; position: absolute; height: 75px; width: 457px"
               PageSize="3"  allowpaging="true" onpageindexchanging="GridView2_PageIndexChanging"     onselectedindexchanged="GridView2_SelectedIndexChanged" >
           <RowStyle HorizontalAlign="Center" />
           <Columns >
               <asp:CommandField ShowSelectButton="True" />
               <asp:BoundField DataField="reg_id" HeaderText="reg_id"
                   SortExpression="reg_id" />
               <asp:BoundField   DataField="reg_date" HeaderStyle-Width="120"    HeaderText="regd date"  SortExpression="reg_date"   />
               <asp:BoundField  DataField="noofitems" HeaderText="noofitems"
                   SortExpression="noofitems" />
               <asp:BoundField DataField="amtdue" HeaderText="amtdue"
                   SortExpression="amtdue" />
           <asp:BoundField DataField="eligibile_days" HeaderText="eligibile_days"
                   SortExpression="eligibile_days" />
           </Columns>
            <SelectedRowStyle BackColor="#FF6666" />
           <HeaderStyle BackColor="#99CCFF" />
           <AlternatingRowStyle BackColor="#99CCFF" HorizontalAlign="Center" />
       </asp:GridView>
Posted
Updated 6-May-13 7:40am
v2
Comments
joshrduncan2012 6-May-13 12:15pm    
"but not working out" means what? Are you getting an error? If no error, does the width not expand/shrink? Please elaborate more as to what output you are getting.
ZurdoDev 6-May-13 12:21pm    
You have a width on your gridview so your columns aren't going to go wider.

1 solution

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