
- Forum
- Programming Talk
- Microsoft .NET
- How to display multiple textboxes on a single line
How to display multiple textboxes on a single line
This is a discussion on How to display multiple textboxes on a single line within the Microsoft .NET forums, part of the Programming Talk category; How do I display multiple textboxes on a single line in a etailsView> control? For example I have 2 textboxes ...
-
05-24-2009, 02:08 PM #1
- Join Date
- May 2009
- Answers
- 1
How to display multiple textboxes on a single line
How do I display multiple textboxes on a single line in a
etailsView> control? For example I have 2 textboxes Category Name and Category Description. I want both textbox controls on a single line. The code that displays them on separate lines is as follows: Code:
Last edited by admin; 02-01-2012 at 01:11 PM.
-
Couldn't see your code at all coz it got rendered as html

Here's what I could take out from View Source:
HTML Code:<asp:DetailsView AutoGenerateRows="False" DataSourceID="DetailsViewDataSource" DataKeyNames="CategoryId" CssClass="Table" HeaderText="Category Details" RowStyle-CssClass="ContentSmall" ID="dvCategory" runat="server" AutoGenerateEditButton="True" AutoGenerateInsertButton="True" OnItemInserted="dvCategory_ItemInserted" OnItemUpdated="dvCategory_ItemUpdated" OnDataBound="dvCategory_DataBound" OnModeChanging="dvCategory_ModeChanging" Width="367px"> <fields> <asp:templatefield sortexpression="CategoryName" headertext="Category"> <edititemtemplate> <asp:textbox text="<%# Bind("CategoryName") %>" runat="server" id="EditCategoryName"></asp:textbox> <asp:requiredfieldvalidator tooltip="Category Name is required." runat="server" id="CategoryNameRequired" errormessage="Category Name is required." controltovalidate="EditCategoryName">*</asp:requiredfieldvalidator> <asp:textbox text="<%# Bind("Description") %>" runat="server" id="EditDescription"></asp:textbox> <asp:requiredfieldvalidator tooltip="Category Description is required." runat="server" id="DescriptionRequired" errormessage="Description is required." controltovalidate="EditDescription">*</asp:requiredfieldvalidator> <cc1:validatorcalloutextender targetcontrolid="CategoryNameRequired" runat="server" id="ValidatorCalloutExtender2"></cc1:validatorcalloutextender> <cc1:validatorcalloutextender targetcontrolid="DescriptionRequired" runat="server" id="ValidatorCalloutExtender4"></cc1:validatorcalloutextender> </edititemtemplate> <insertitemtemplate> <asp:textbox text="<%# Bind("CategoryName") %>" runat="server" id="InsertCategoryName"></asp:textbox> <asp:requiredfieldvalidator tooltip="Category Name is required." runat="server" id="CategoryNameRequired" errormessage="Category Name is required." controltovalidate="InsertCategoryName">*</asp:requiredfieldvalidator> <asp:textbox text="<%# Bind("Description") %>" runat="server" id="InsertDescription"></asp:textbox> <asp:requiredfieldvalidator tooltip="Category Description is required." runat="server" id="DescriptionRequired" errormessage="Description is required." controltovalidate="InsertDescription">*</asp:requiredfieldvalidator> <cc1:validatorcalloutextender targetcontrolid="CategoryNameRequired" runat="server" id="ValidatorCalloutExtender1"></cc1:validatorcalloutextender> <cc1:validatorcalloutextender targetcontrolid="DescriptionRequired" runat="server" id="ValidatorCalloutExtender3"></cc1:validatorcalloutextender> </insertitemtemplate> <itemtemplate> <asp:label text="<%# Bind("CategoryName") %>" runat="server" id="Label1"></asp:label> - <asp:label text="<%# Bind("Description") %>" runat="server" id="Label2"></asp:label> </itemtemplate> </asp:templatefield> </fields> </asp:DetailsView>
The problem is you have just been placing the controls (textboxes) without using any kind of alignment. With validator controls cluttered in between, you will never know how browsers would display those out.
Try to align your textboxes using table cells and that should align your textboxes on the same row. It would also be advisable to set the validator controls dynamic, but you may want to play around with it to see if it suits your alignment. Here's what you could do
HTH!!!HTML Code:<asp:DetailsView AutoGenerateRows="False" DataSourceID="DetailsViewDataSource" DataKeyNames="CategoryId" CssClass="Table" HeaderText="Category Details" RowStyle-CssClass="ContentSmall" ID="dvCategory" runat="server" AutoGenerateEditButton="True" AutoGenerateInsertButton="True" OnItemInserted="dvCategory_ItemInserted" OnItemUpdated="dvCategory_ItemUpdated" OnDataBound="dvCategory_DataBound" OnModeChanging="dvCategory_ModeChanging" Width="367px"> <fields> <asp:templatefield sortexpression="CategoryName" headertext="Category"> <edititemtemplate> <table cellpadding="0" cellspacing="2" border="0"> <tr> <td><asp:textbox text="<%# Bind("CategoryName") %>" runat="server" id="EditCategoryName"></asp:textbox></td> <td><asp:requiredfieldvalidator tooltip="Category Name is required." runat="server" id="CategoryNameRequired" errormessage="Category Name is required." controltovalidate="EditCategoryName" Display="Dynamic">*</asp:requiredfieldvalidator></td> <td><asp:textbox text="<%# Bind("Description") %>" runat="server" id="EditDescription"></asp:textbox></td> <td><asp:requiredfieldvalidator tooltip="Category Description is required." runat="server" id="DescriptionRequired" errormessage="Description is required." controltovalidate="EditDescription" Display="Dynamic">*</asp:requiredfieldvalidator></td> <td><cc1:validatorcalloutextender targetcontrolid="CategoryNameRequired" runat="server" id="ValidatorCalloutExtender2" Display="Dynamic"></cc1:validatorcalloutextender> <cc1:validatorcalloutextender targetcontrolid="DescriptionRequired" runat="server" id="ValidatorCalloutExtender4" Display="Dynamic"></cc1:validatorcalloutextender></td> </tr> </table> </edititemtemplate> <insertitemtemplate> <table cellpadding="0" cellspacing="2" border="0"> <tr> <td><asp:textbox text="<%# Bind("CategoryName") %>" runat="server" id="InsertCategoryName"></asp:textbox></td> <td><asp:requiredfieldvalidator tooltip="Category Name is required." runat="server" id="CategoryNameRequired" errormessage="Category Name is required." controltovalidate="InsertCategoryName" Display="Dynamic">*</asp:requiredfieldvalidator></td> <td><asp:textbox text="<%# Bind("Description") %>" runat="server" id="InsertDescription"></asp:textbox></td> <td><asp:requiredfieldvalidator tooltip="Category Description is required." runat="server" id="DescriptionRequired" errormessage="Description is required." controltovalidate="InsertDescription" Display="Dynamic">*</asp:requiredfieldvalidator></td> <td><cc1:validatorcalloutextender targetcontrolid="CategoryNameRequired" runat="server" id="ValidatorCalloutExtender1" Display="Dynamic"></cc1:validatorcalloutextender> <cc1:validatorcalloutextender targetcontrolid="DescriptionRequired" runat="server" id="ValidatorCalloutExtender3" Display="Dynamic"></cc1:validatorcalloutextender></td> </tr> </table> </insertitemtemplate> <itemtemplate> <table cellpadding="0" cellspacing="2" border="0"> <tr> <td><asp:label text="<%# Bind("CategoryName") %>" runat="server" id="Label1"></asp:label></td> <td> - </td> <td><asp:label text="<%# Bind("Description") %>" runat="server" id="Label2"></asp:label></td> </tr> </table> </itemtemplate> </asp:templatefield> </fields> </asp:DetailsView>
-
09-29-2011, 12:36 PM #3
- Join Date
- Feb 2011
- Answers
- 2
the presentation method is very good because first they explain the intitial things and secong phase it is start to describe the main things whick is necessary to explain it.
-
By default, the Windows Forms TextBox control displays a single line of text and does not display scroll bars. If the text is longer than the available space, only part of the text is visible. You can change this default behavior by setting the Multiline, WordWrap, and ScrollBars properties to appropriate values.
...................................
pcb design services
pcb design bureau
-
Sponsored Ads

Reply With Quote





