473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DetailsView fixed columns width - how to?

Hello Developers,

DetailsView control, typically, has two columns: names and values.
How do I define either fixed or minimum width of those columns?
I have tried modifying EditRowStyle and RowStyle width, but with no good
results.
I would appreciate any hints.

Thank you,

Tomasz
Apr 4 '07 #1
7 20339
Hi Tomasz,

You can set the DetailsView's width to a fixed value and use
FieldHeaderStyle-Width attribute to set the "name" field's width; the
"value" field's width can be determined by them:

<asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" DataSourceID="ObjectDataSource1"
Height="50px" Width="800px" FieldHeaderStyle-Width="400px">
Let me know if this works on your side.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 5 '07 #2
Hello Walter,

Thank you for your response.

Is there any way I can set fixed "value column" width, while allowing the
"name column" change its width dynamically?

Typically, you do not know the "name column" size but you also do not want
"name labels" wrap, and you want to leave enough, arbitrary specified space
for the user input - the "value column" size. I think this is the most
common scenario.

I am sure many other developers already came across this problem.

Respectfully,

Tomasz

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:NK**************@TK2MSFTNGHUB02.phx.gbl...
Hi Tomasz,

You can set the DetailsView's width to a fixed value and use
FieldHeaderStyle-Width attribute to set the "name" field's width; the
"value" field's width can be determined by them:

<asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" DataSourceID="ObjectDataSource1"
Height="50px" Width="800px" FieldHeaderStyle-Width="400px">
Let me know if this works on your side.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 5 '07 #3
Hi Tomasz,

To do that, set either field's ItemStyle-Width attribute. For example:

<asp:DetailsView...
<Fields>
<asp:BoundField ItemStyle-Width="400px" ...
Since the fields are displayed in one table with two columns, the last <td>
that has a width setting will determine the entire column's width.
Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 6 '07 #4
Thanks. I was affraid there was no better way to solve this problem.
It is especially inconvienient with templates, since the same width should
be set for all three (EditItemTemplate, InsertItemTemplate, ItemTemplate),
which decreases code maintainability.

Tomasz
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Hm**************@TK2MSFTNGHUB02.phx.gbl...
Hi Tomasz,

To do that, set either field's ItemStyle-Width attribute. For example:

<asp:DetailsView...
<Fields>
<asp:BoundField ItemStyle-Width="400px" ...
Since the fields are displayed in one table with two columns, the last
<td>
that has a width setting will determine the entire column's width.
Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 6 '07 #5
Hi Tomasz,

For TemplateField, I believe you also only need to set the ItemStyle-Width
once for the TemplateField element:

<asp:TemplateField ItemStyle-Width="500px">

Like I described in my previous reply, you only need to set this on one of
your field. By the way, please note applying this attribute on the
CommandField will not work since the CommandField spans two columns.

Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 9 '07 #6
Hi Tomasz,

What do you think about above suggestion?

Please feel free to let me know if there's anything else I can help.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 12 '07 #7
Thank you. This is a "good enough" solution. I do not why I did not think
about it!
Tomasz J

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:x5**************@TK2MSFTNGHUB02.phx.gbl...
Hi Tomasz,

For TemplateField, I believe you also only need to set the ItemStyle-Width
once for the TemplateField element:

<asp:TemplateField ItemStyle-Width="500px">

Like I described in my previous reply, you only need to set this on one of
your field. By the way, please note applying this attribute on the
CommandField will not work since the CommandField spans two columns.

Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 12 '07 #8

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

Similar topics

179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
0
by: jeffmagill | last post by:
Hi Everybody, I'm really hoping that someone can help me out because I have spent too much time on this project already! Basically, I have a DetailsView that handles all the Edits for a...
3
by: Jason | last post by:
Anyone know how to make the text wrap in a text box of a DetailsView?
1
by: Marc | last post by:
Hi, I made a detailsview for inserting records. I also made a gridview for editing and deleting the same records. The keyfield is an autonumbering field in Access (pcnr). My problem is: I can...
0
by: sansie | last post by:
Hi, I have a page which is basically a details view(in inset mode) inside a datalist. The problem is I want to set the field "invoiceID" (of the detailsview) to an invoiceID coming through the...
1
by: JJ | last post by:
Hi. I am having trouble getting a dropdownlist to work properly in a detailsview: The code is something like: <asp:DetailsView ID="dvwSubscriber" runat="server" AutoGenerateRows="False" ...
1
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...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
0
by: dayiku | last post by:
I am trying to retrieve values from a boundfield in a detailsview. protected void BtnViewDetails_Click(object sender, EventArgs e) { // get the gridviewrow from the sender so we...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.