Field size in Edit mode

B

bruno

Just a basic question:
I have a very simple gridview with two columns, one sized 20%, the second
80% and the commandfields (Select, Edit, New) at 10%. The first column is the
key.
In edit mode the width of the input field in the second column is too small
and I don't find the way to enlarge it.
How can I do? And how can I change the gridview to obtain a multiline input
field in edit mode?
Thanks
 
W

Walter Wang [MSFT]

Hi Bruno,

Please use following code as an example, I'm using the Products table from
NorthWind database as an example:

<form id="form1" runat="server">
<div>
<asp:GridView Width="100%" ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ProductID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField ControlStyle-Width="20%"
DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:TemplateField ControlStyle-Width="75%">
<ItemTemplate>
<asp:Label ID="lblProductName" runat="server"
Text='<%# Eval("ProductName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtProductName" runat="server"
TextMode="MultiLine" Text='<%# Bind("ProductName") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ControlStyle-Width="5%"
ShowSelectButton="True" ShowEditButton="true" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName] FROM
[Alphabetical list of products]">
</asp:SqlDataSource>

</div>
</form>

Please tell me whether or not this helps. Thanks.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top