Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I keep the size as it is before and after any row added to the gridview?
Here code for Gridview
ASP.NET
<asp:GridView ID="GridViewMBOFuncObjDetalis" runat="server"  DataKeyNames="id" AutoGenerateColumns="false"
                                 Style="margin-left:10px;margin-right:10px; text-align: left" Width="946px" 
ShowFooter="true"   >
     <columns>
         <asp:BoundField DataField="MBO_Objective"    HeaderText="Function related objectives" />
         <asp:BoundField DataField="MBO_Measured_Var" HeaderText="Measured variable" />
         <asp:BoundField DataField="MBO_Target_Date" HeaderText="Target Date" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="10px" >
           <itemstyle horizontalalign="Center" width="10px" />
          
         <asp:BoundField DataField="MBO_Weighting_Factor_Emp"  HeaderText="Weighting Factor" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="60px" >
          <itemstyle horizontalalign="Center" width="60px" />
          
         <asp:TemplateField ItemStyle-HorizontalAlign ="Center" FooterStyle-HorizontalAlign="Center" >
           <itemtemplate>
         <asp:ImageButton ID="imgbtnEdit"  runat="server" height="16px" Width="16px" ToolTip="Edit" ImageUrl="~/Images/Edit.jpg" onclick="imgbtnEdit_Click" />
           </itemtemplate>
        <footerstyle horizontalalign="Center" />
        <itemstyle horizontalalign="Center" />
                                 

 <asp:TemplateField ItemStyle-HorizontalAlign ="Center" FooterStyle-HorizontalAlign="Center" >
     <itemtemplate>
  <asp:ImageButton ID="imgbtnDelete" runat="server" CommandName ="Delete" height="16px" Width="16px" CommandArgument = '<%# Eval("id")%>' 
                                 OnClientClick = "return confirm('Do you want to delete?')"
                                Text = "Delete" ToolTip="Delete" ImageUrl="~/Images/Delete.png" onclick="DeleteFuncObjDetails"/>

  </itemtemplate>
  <footertemplate>
             <asp:ImageButton ID="imgbtnAdd" runat="server" CommandName="Add" height="16px" Width="16px" ToolTip="Add" ImageUrl="~/Images/Add.jpg" onclick="imgbtnAdd_Click" />
         </footertemplate>
  <footerstyle horizontalalign="Center" />
  <HeaderStyle Wrap="False" />
  <itemstyle horizontalalign="Center" />
  
</columns>
<alternatingrowstyle backcolor="#DBEED5" />
<HeaderStyle BackColor="#81C26D" />
<rowstyle bordercolor="Black" borderstyle="Dotted" borderwidth="1px" />



[Edit member="Tadit"]
Added pre tags.
[/Edit]
Posted
v3
Comments
Siva Hyderabad 28-Apr-14 0:59am    
Gridview has properities like..<br>
Widht = "200px" Height = "200px" ..
[no name] 28-Apr-14 1:03am    
If you are not giving size of gridview width then width will change as per no of columns
Ni!E$H_WAGH 28-Apr-14 1:12am    
That's not issue . The issue is how do keep size before adding and after adding data to gridview .
DamithSL 28-Apr-14 1:27am    
can you update the question with your aspx page code?
Ni!E$H_WAGH 28-Apr-14 1:43am    
Updated question with Gridview code

you have define the column size unless it will stretch to maximum value data length
 
Share this answer
 
Hi, Ni!E$H_UPDATED,

<asp:gridview id="GridViewMBOFuncObjDetalis" runat="server" datakeynames="id" autogeneratecolumns="false" xmlns:asp="#unknown">
Style="margin-left:10px;margin-right:10px; text-align: left" Width="100%"
ShowFooter="true" >


Just change gridview WIDTH property with % your gridivew won't be change.

Let me know if you have any further query.

Please, go through above suggestion.

If its your answer, please mark as solution.

Best of luck for hunting solutions.

Thank you.

Regards,

Manoj Kalla
 
Share this answer
 

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