We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

.net datagrid autoGenerateColumns=true words wrap, how to prevent?

ee_id
ee_id asked
on
Medium Priority
2,250 Views
Last Modified: 2012-08-13

Hello,

I am trying to prevent the words from wrapping in the DataGrid cells when the datagrid is autogenerating the columns.  I have used "ItemStyle-Wrap=False AlternatingItemStyle-Wrap=False" of the datagrid tag and "Wrap=False" of the ItemStyle tag.  Nothing works!  

Any help would be great!
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
The wrap functionality occurs for each cell and not for each row of the DataGrid. Therefore, if you set the wrap functionality for all of the DataGrid, text wrapping functionality is not disabled for every row or column

Author

Commented:

Thanks very much for the work around, nice to know it is a bug!
For posterity:

If you are dynamincally building your datagrid (number of columns and their names might be different), this is how you'd do the workaround:

    DataGrid1.DataBind();
    foreach(DataGridColumn dgc in DataGrid1.Columns)
    {
        dgc.ItemStyle.Wrap = false;
    }

Note that you would want to add this code after the DataBind().

HTH,
Nathan

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.