473,401 Members | 2,068 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,401 software developers and data experts.

DataGrid Column

Tap
How can I restrict the datagrid column to display only 40 characters per line, and wrap the rest.

e.g. If the column string is 2000 characters, i would like to wrap it at 41st character. The column width should not increase more than 40 characters. Somehow its going out of the screen whenever I have tried to set it

Thanks

Ta

Nov 15 '05 #1
4 2072
if you are talking about an ASP.NET app, realize that ultimately, all
DataGrid's are rendered as <table> ... <tr> ... <td> ... </td> ... </tr> ...
</table>

so you can write code into your page's PreRender event to look for those
<td> ... </td> tags with text that is in excess of 40 characters and
modify them (i.e. embed a <table> inside of the <td>) to have multiple lines
of only 40 characters each.
"Tap" <an*******@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...
How can I restrict the datagrid column to display only 40 characters per line, and wrap the rest.
e.g. If the column string is 2000 characters, i would like to wrap it at 41st character. The column width should not increase more than 40
characters. Somehow its going out of the screen whenever I have tried to set
it.
Thanks,

Tap

Nov 15 '05 #2
Tap
So, There is no way it does automatically by setting DataFormatting string for the column

Could you please guide me with some code in the PreRender event

Thanks

Ta

Nov 15 '05 #3
Remember that ultimately, everything ASP.NET does is to render simple HTML to the clients.
The PreRender event lets you grab that rendered HTML and modify it before it actually goes to
the client...
// iterate through each row of your grid
foreach( DataGridItem dgItem in myGrid.Items )
{
// iterate through each cell of your row
foreach( TableCell tc in dgItem.Cells )
{
// iterate through each control in your cell
foreach( Control ctl in tc.Controls )
{
// check for text here and then replace
// with trimmed...
// strLong.SubString(0,40) + "<br>" +
// strLong.SubString(41,81) + "<br>" ...

}
}
}
"Tap" <an*******@discussions.microsoft.com> wrote in message news:E8**********************************@microsof t.com...
So, There is no way it does automatically by setting DataFormatting string for the column ?

Could you please guide me with some code in the PreRender event ?

Thanks,

Tap

Nov 15 '05 #4
Tap
Thanks for the quick response

Nov 15 '05 #5

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

Similar topics

5
by: Jean Carlo | last post by:
Hello guys I`m developing a windows form that contain one Datagrid. In this datagrid I insert a checkBox Column. I need to get all rows where checkbox is checked by user. How do I get this...
3
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
4
by: Anthony | last post by:
Hi Folks, I'm adding some columns to my datagrid which are of Combo Box type. I'm inheriting DataGridTextBoxColumn and doing all the usual stuff to get them populated. This is working fine. I...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
4
by: Jeff | last post by:
I am stuck on trying to generate two columns headers for a datagrid on form load. I can use a datatable as the datasource and get the results I want, but I want to set different column widths and...
3
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
10
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option....
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...
0
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...

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.