473,756 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DetailsView formatting

The default format for the DetailsView control is for there to be a row
per field. Is it possible set it to show more than one column per row
(see below)?

ID ... Name ...
Address ... Country ...

etc. I have tried to add <tr>'s and <td>'s within the DetailsView to do
this, but it just causes errors.

Anybody know if this can be done, and if so how?

*** Sent via Developersdex http://www.developersdex.com ***
Apr 28 '06 #1
5 11345
Just use Template fields, you could put every column repeated 15 times in one
row if you want. E.g.

<asp:DetailsVie w ID="dvwCustomer Details" runat="server"
DataSourceID="s dsCustomerDetai ls" AutoGenerateRow s="False">
<Fields>
<asp:TemplateFi eld HeaderText="Rou nd Number">
<ItemStyle CssClass="detai ls-view-cells" />
<HeaderStyle CssClass="detai ls-view-header" />
<ItemTemplate >
<asp:TextBox ID="txbRoundNum ber"
runat="server" Text='<%#Bind(" analysis_codes1 ") %>' MaxLength="10">

</asp:TextBox>
<asp:HiddenFiel d id="hdnPriceLis t"
runat="server" Value='<%#Bind( "price_list ") %>'>
</asp:HiddenField >
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Dri ver Number">
<ItemStyle CssClass="detai ls-view-cells" />
<HeaderStyle CssClass="detai ls-view-header" />
<ItemTemplate >
<asp:TextBox ID="txbDriverNu mber"
runat="server" Text='<%#Bind(" analysis_codes3 ") %>' MaxLength="10">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateFie ld>
</Fields>
</asp:DetailsView >

"Mike P" wrote:
The default format for the DetailsView control is for there to be a row
per field. Is it possible set it to show more than one column per row
(see below)?

ID ... Name ...
Address ... Country ...

etc. I have tried to add <tr>'s and <td>'s within the DetailsView to do
this, but it just causes errors.

Anybody know if this can be done, and if so how?

*** Sent via Developersdex http://www.developersdex.com ***

Apr 28 '06 #2
Hi,

I am using Template fields, but it seems that they are automatically put
on different rows :

<asp:DetailsVie w ID="DetailsView 1" runat="server"
DataSourceID="S qlDataSource1"
DataKeyNames="O pportunityID"
AutoGenerateRow s="False">
<Fields>
<asp:BoundFie ld HeaderText="ID"
DataField="Oppo rtunityID" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:TemplateFi eld HeaderText="Pro duct Type"
SortExpression= "ProductTyp e">
<ItemTemplate >
<asp:Label ID="lblProductT ype"
Text='<%# Eval("ProductTy pe") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st
ID="ddlProductT ype" runat="server" DataSourceID="S qlDataSource2"

DataTextField=" ProductType" DataValueField= "ProductTyp eID"
SelectedValue=' <%#
Bind("ProductTy peID") %>'></asp:DropDownLis t>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Opp ortunity
Type" SortExpression= "OpportunityTyp e">
<ItemTemplate >
<asp:Label ID="lblOpportun ityType"
Text='<%# Eval("Opportuni tyType") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlOpportun ityType"
DataSourceID="S qlDataSource3" Runat="Server"
DataTextField=" OpportunityType "
DataValueField= "OpportunityTyp eID" SelectedValue=' <%#
Bind("Opportuni tyTypeID") %>'/>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Val ue (£)"
SortExpression= "MonetaryValue" >
<ItemTemplate >
<asp:Label ID="lblValue" Text='<%#
Eval("MonetaryV alue") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtValue" Text='<%#
Bind("MonetaryV alue") %>' runat="server"> </asp:TextBox>
<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator1" runat="server"
ControlToValida te="txtValue"
Display="None" ErrorMessage="P lease enter a Value" />
<asp:RangeValid ator ID="RangeValida tor1"
runat="server"
ControlToValida te="txtValue"
Type="Double" MaximumValue="4 000000"
MinimumValue="0 " Display="None"
ErrorMessage="V alue must be numeric" />
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Des cription"
SortExpression= "Descriptio n">
<ItemTemplate >
<asp:Label ID="lblDescript ion" Text='<%#
Eval("Descripti on") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtDescript ion"
Text='<%# Bind("Descripti on") %>' runat="server"
TextMode="Multi Line" Rows="10"
Columns="50"></asp:TextBox>
<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator2" runat="server"
ControlToValida te="txtDescript ion"
Display="None" ErrorMessage="P lease enter a Description" />
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Pro bability
(%)" SortExpression= "Probabilit y" >
<ItemTemplate >
<asp:Label ID="lblProbabil ity" Text='<%#
Eval("Probabili ty") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlProbabil ity"
DataSourceID="S qlDataSource4" Runat="Server"
DataTextField=" Probability"
DataValueField= "Probabilit yID" SelectedValue=' <%# Bind("Probabili tyID")
%>'/>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Loc ation"
SortExpression= "Location">
<ItemTemplate >
<asp:Label ID="lblLocation " Text='<%#
Eval("Location" ) %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtLocation " Text='<%#
Bind("Location" ) %>' runat="server"> </asp:TextBox>
<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator3" runat="server"
ControlToValida te="txtLocation "
Display="None" ErrorMessage="P lease enter a Location" />
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:BoundFie ld HeaderText="Com pany Name"
DataField="Comp anyName" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:BoundFie ld HeaderText="Dat e Created"
DataField="Date Created" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:TemplateFi eld HeaderText="Sta tus"
SortExpression= "OpportunitySta tus">
<ItemTemplate >
<asp:Label ID="lblOpportun ityStatus"
Text='<%# Eval("Opportuni tyStatus") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st
id="ddlOpportun ityStatus" DataSourceID="S qlDataSource5" Runat="Server"
DataTextField=" OpportunityStat us"
DataValueField= "OpportunitySta tusID" SelectedValue=' <%#
Bind("Opportuni tyStatusID") %>'/>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:BoundFie ld HeaderText="Dat e Won/Lost"
DataField="Date WonOrLost" NullDisplayText ="N/A" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:CommandFie ld ShowEditButton= "True"
ButtonType="Ima ge" EditImageUrl="~/Images/btnEdit.jpg"
CancelImageUrl= "~/Images/btnCancel.jpg"
UpdateImageUrl= "~/Images/btnUpdate.jpg" >
<ItemStyle Height="10px" />
</asp:CommandFiel d>

</Fields>
</asp:DetailsView >
*** Sent via Developersdex http://www.developersdex.com ***
Apr 28 '06 #3
Yes but there is nothing stopping you putting whatever you want within
however many or few template fierlds as you want. The markup below looks
like what gets generated when you turn BoundFields into TemplateFields. Now
edit it to be how you want it. If you want two items in one template field
simply cut and paste the contents of each ItemTemplate, UpdateTemplate and
InsertTemplate from one templatefield to another and delete the extra
templatefield. The dta is bound to the controls within the templatefield,
the templatefield it's self is just a container and does not have any data
bound to it.

"Mike P" wrote:
Hi,

I am using Template fields, but it seems that they are automatically put
on different rows :

<asp:DetailsVie w ID="DetailsView 1" runat="server"
DataSourceID="S qlDataSource1"
DataKeyNames="O pportunityID"
AutoGenerateRow s="False">
<Fields>
<asp:BoundFie ld HeaderText="ID"
DataField="Oppo rtunityID" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:TemplateFi eld HeaderText="Pro duct Type"
SortExpression= "ProductTyp e">
<ItemTemplate >
<asp:Label ID="lblProductT ype"
Text='<%# Eval("ProductTy pe") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st
ID="ddlProductT ype" runat="server" DataSourceID="S qlDataSource2"

DataTextField=" ProductType" DataValueField= "ProductTyp eID"
SelectedValue=' <%#
Bind("ProductTy peID") %>'></asp:DropDownLis t>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Opp ortunity
Type" SortExpression= "OpportunityTyp e">
<ItemTemplate >
<asp:Label ID="lblOpportun ityType"
Text='<%# Eval("Opportuni tyType") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlOpportun ityType"
DataSourceID="S qlDataSource3" Runat="Server"
DataTextField=" OpportunityType "
DataValueField= "OpportunityTyp eID" SelectedValue=' <%#
Bind("Opportuni tyTypeID") %>'/>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Val ue (#)"
SortExpression= "MonetaryValue" >
<ItemTemplate >
<asp:Label ID="lblValue" Text='<%#
Eval("MonetaryV alue") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtValue" Text='<%#
Bind("MonetaryV alue") %>' runat="server"> </asp:TextBox>
<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator1" runat="server"
ControlToValida te="txtValue"
Display="None" ErrorMessage="P lease enter a Value" />
<asp:RangeValid ator ID="RangeValida tor1"
runat="server"
ControlToValida te="txtValue"
Type="Double" MaximumValue="4 000000"
MinimumValue="0 " Display="None"
ErrorMessage="V alue must be numeric" />
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Des cription"
SortExpression= "Descriptio n">
<ItemTemplate >
<asp:Label ID="lblDescript ion" Text='<%#
Eval("Descripti on") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtDescript ion"
Text='<%# Bind("Descripti on") %>' runat="server"
TextMode="Multi Line" Rows="10"
Columns="50"></asp:TextBox>
<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator2" runat="server"
ControlToValida te="txtDescript ion"
Display="None" ErrorMessage="P lease enter a Description" />
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Pro bability
(%)" SortExpression= "Probabilit y" >
<ItemTemplate >
<asp:Label ID="lblProbabil ity" Text='<%#
Eval("Probabili ty") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="ddlProbabil ity"
DataSourceID="S qlDataSource4" Runat="Server"
DataTextField=" Probability"
DataValueField= "Probabilit yID" SelectedValue=' <%# Bind("Probabili tyID")
%>'/>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Loc ation"
SortExpression= "Location">
<ItemTemplate >
<asp:Label ID="lblLocation " Text='<%#
Eval("Location" ) %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtLocation " Text='<%#
Bind("Location" ) %>' runat="server"> </asp:TextBox>
<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator3" runat="server"
ControlToValida te="txtLocation "
Display="None" ErrorMessage="P lease enter a Location" />
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:BoundFie ld HeaderText="Com pany Name"
DataField="Comp anyName" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:BoundFie ld HeaderText="Dat e Created"
DataField="Date Created" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:TemplateFi eld HeaderText="Sta tus"
SortExpression= "OpportunitySta tus">
<ItemTemplate >
<asp:Label ID="lblOpportun ityStatus"
Text='<%# Eval("Opportuni tyStatus") %>' Runat="Server" />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st
id="ddlOpportun ityStatus" DataSourceID="S qlDataSource5" Runat="Server"
DataTextField=" OpportunityStat us"
DataValueField= "OpportunitySta tusID" SelectedValue=' <%#
Bind("Opportuni tyStatusID") %>'/>
</EditItemTemplat e>
<ItemStyle Height="24px" />
</asp:TemplateFie ld>

<asp:BoundFie ld HeaderText="Dat e Won/Lost"
DataField="Date WonOrLost" NullDisplayText ="N/A" ReadOnly="True" >
<ItemStyle Height="24px" />
</asp:BoundField>

<asp:CommandFie ld ShowEditButton= "True"
ButtonType="Ima ge" EditImageUrl="~/Images/btnEdit.jpg"
CancelImageUrl= "~/Images/btnCancel.jpg"
UpdateImageUrl= "~/Images/btnUpdate.jpg" >
<ItemStyle Height="10px" />
</asp:CommandFiel d>

</Fields>
</asp:DetailsView >
*** Sent via Developersdex http://www.developersdex.com ***

Apr 28 '06 #4
How does this work if you have mixture of Bound Fields and Template
Fields, since you are not allowed to put Bound Fields within Template
Fields?

*** Sent via Developersdex http://www.developersdex.com ***
Apr 28 '06 #5
Boundfields are of faily limited use, i rarely use them at all. There is
never a circumstance where it would be usefull to put a boundfield inside a
templatefield. If you want the value from a bound field to be inside a
template field. simply delete the boundfield put another control in
itemtemplate, edittemplate and/or inserttemplate sections of the the
templatefield as apropraite. Then bind that control to the relevent column
within your table using the following syntax.

<asp:textbox id="MyTextBox" runat="server" text='<%#
Bind("FieldName ")%>'></asp:textbox>

Remember, BoundFields are just a quick way of displaying data from a
database, they are almost useless for updateing and inserting data and are of
only limited use for displaying data, as you have discovered.

"Mike P" wrote:
How does this work if you have mixture of Bound Fields and Template
Fields, since you are not allowed to put Bound Fields within Template
Fields?

*** Sent via Developersdex http://www.developersdex.com ***

Apr 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10073
by: Shawn Wildermuth | last post by:
I have a *single* SqlDataSource that loads up a single result set that I show in a GridView. In the GridView, i've added a "Select" button and handling the SelectedItem event. I also have a DetailsView (though FormView has this same issue) where I want to be able to set the current item to bind to from the DataSource. All the examples I've seen use two data sources and on every *select* they do another round-trip to the Database (which...
12
8704
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
1
4439
by: sck10 | last post by:
Hello, I am trying to change a value when a user goes into edit mode on a DetailsView control. I am trying to use the following, but can not figure out how to get to the bound field ("MyBoundField") to set its new value. Any help with this would be appreciated. Sub EmployeeDetailView_ModeChanged(ByVal sender As Object, ByVal e As EventArgs) Select Case CustomerDetailView.CurrentMode
4
16066
by: Frits van Soldt | last post by:
Hello, I hope somebody can help me with this! I have 2 listboxes in the edititemtemplate of a detailsview. In the databound event of the detailsview I would like to fill the listboxes programmatically (not through databinding). If I use detailsview.findcontrol(controlname) then an empty object is returned. How can I address these controls? Thank you for your time.
1
1221
by: Marko Loukkaanhuhta | last post by:
Hi, this might be newbies question, but hey I'm newbie.. I'm trying to make a web site which you can use to read and update data from sql server. Data on the sql server is text. Data fields in sql server are ntext type. Ok, I've managed to read data and update data to the sql server from my website, however even if my text contains (at least in the sql server and in edit box) carriage returns, like paragraphs made by return key, like...
0
2554
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the sample provided by Microsoft and other comminity sites. Most of the samples were using Databinding using a DesignTime "SqlDataSource" Control and assigning its ID to DataSourceID property of DetailsView. However, in all of my application we DO...
2
3021
by: Curious Trigger | last post by:
Hello, if have an asp.net web page with a detailsview. This detailsview uses a sqldatasource connecting to a sql server 2005 database with a select statement simliar to this one: SELECT warning_threshold, critical_threshold, weight FROM thresholds UPDATE thresholds SET warning_threshold=@warning_threshold, critical_threshold=@critical_threshold, weight =@weight I also added insert and delete statements to this datasource.
1
5029
by: needhelp1 | last post by:
I have gridview with a detailsview below. When I click on 'New' in brings up the DetailsView for inserting. When I click on 'Edit' in does not brink up the DetailsView. What am I doing wrong? I totally at a loss, please help. I don't know if I need to something to grdUserProfile_RowEditing. Thank you! This is some of my code behind: protected void grdUserProfile_RowEditing(object sender, GridViewEditEventArgs e) { } protected void...
5
3463
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration: default.aspx:
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.