I would have my Gridview User Control In gray frame(its div tag) whether Gridview is in editmode or not, I did use Gridview's Width and Styles but it didn't work. How do I do this?
.GridViewStyle
{
/*It didn't work*/
width:50%;
}
Gridview when its in edit mode
Gridview when its not in edit mode
To disable editing for the entire grid, setting the AllowEditing property to False either in the designer or in code.
The GridView control is used to display the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features: Binding to data source controls, such as SqlDataSource. Built-in sort capabilities.
GridView is a control used to display data in tables on a web page. It displays data in both rows and columns, where each column represents a field, and each row represents a record. GridView helps to perform key activities like Insert, Delete, Sorting, and Paging.
The issue is certainly the size of the <input />
text boxes when in edit mode
Add the <EditRowStyle>
element to your gridview to give the edit row a CSS class
<asp:GridView ID="GridView1" runat="server">
...
<EditRowStyle CssClass="GridViewEditRow" /> <%-- add this --%>
</asp:GridView>
Now you can control the size of the textboxes with CSS
.GridViewEditRow input[type=text] {width:50px;} /* size textboxes */
.GridViewEditRow select {width:50px;} /* size drop down lists */
It seems some controls that are visible in edit mode (the textbox inputs mainly) have a certain width, making the entire grid too wide. Your browser will do the best it can to set the width of the table (which is what a gridview renders to), but if the contents are too wide, it will have to make it wider than you wanted it to.
Inspect the textbox elements with Firebug (if you're using Firefox), Developer Tools (Internet Explorer), ... See if they have a width set to them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With