I would have a custom Gridview control. In the gray frame (its div tag) whether the Gridview was in the editmode or not, I used Gridview Width and Styles, but this did not work. How to do it?
.GridViewStyle { /*It didn't work*/ width:50%; }
Gridview when it is in edit mode
Gridview when it is not in edit mode
The problem, of course, is the size of the text fields <input />in edit mode
<input />
Add an element <EditRowStyle>to gridview to give the edit line a CSS class
<EditRowStyle>
<asp:GridView ID="GridView1" runat="server"> ... <EditRowStyle CssClass="GridViewEditRow" /> <%-- add this --%> </asp:GridView>
Now you can control the size of text fields using CSS
.GridViewEditRow input[type=text] {width:50px;} /* size textboxes */ .GridViewEditRow select {width:50px;} /* size drop down lists */
, , ( ), , . , ( , gridview), , , .
Firebug ( Firefox), (Internet Explorer),... , , .
, , xaml div. , . div, . , .
<div style="width:100px; height:100px; overflow:scroll;"> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div>
<asp:BoundField HeaderText="Title" ControlStyle-Width="100px" DataField="Title" />
use the ControlStyle-Width attribute and assign the width to the column
The following works:
<asp:TemplateField HeaderText="Salary" ControlStyle-CssClass="cssWidth"></asp:TemplateField> <style type="text/css"> .cssWidth { width : 150px; } </style>