HighTechTalks DotNet Forums  

Field size in Edit mode

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Field size in Edit mode in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
bruno
 
Posts: n/a

Default Field size in Edit mode - 09-07-2006 , 05:55 PM






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
--
bruno

Reply With Quote
  #2  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: Field size in Edit mode - 09-07-2006 , 09:39 PM






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 (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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


Reply With Quote
  #3  
Old   
bruno
 
Posts: n/a

Default RE: Field size in Edit mode - 09-08-2006 , 03:03 AM



many thanks Walter.
--
bruno


"Walter Wang [MSFT]" wrote:

Quote:
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 (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.