473,326 Members | 2,126 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,326 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 2067
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.