introlux
asked on
Gridview Cell Display Help c#
Hi,
I would like to ensure that the data is wrapped for two rows of space. I am setting the width for each cell like this:
cell.Style["Width"] = "100px";
For each row I have this code:
protected void GridView1_RowCreated(objec t sender, GridViewRowEventArgs e)
{
foreach (TableCell cell in e.Row.Cells)
{
cell.Wrap = false;
cell.Style["overflow"] = "hidden";
cell.Style["text-overflow" ] = "ellipsis";
}
}
I would onlly like it to display two rows height, with a width of 100px. If it goes over this to display the ellipsis.
Any idea??
Regards,
introlux
I would like to ensure that the data is wrapped for two rows of space. I am setting the width for each cell like this:
cell.Style["Width"] = "100px";
For each row I have this code:
protected void GridView1_RowCreated(objec
{
foreach (TableCell cell in e.Row.Cells)
{
cell.Wrap = false;
cell.Style["overflow"] = "hidden";
cell.Style["text-overflow"
}
}
I would onlly like it to display two rows height, with a width of 100px. If it goes over this to display the ellipsis.
Any idea??
Regards,
introlux
ASKER
Compiler Error Message: CS0029: Cannot implicitly convert type 'System.Web.UI.WebControls .Unit' to 'string'
Source Error:
Line 243: cell.Style["overflow"] = "hidden";
Line 244: cell.Style["text-overflow" ] = "ellipsis";
Line 245: cell.Style["Width"] = Unit.Pixel(100);
Line 246: }
Source Error:
Line 243: cell.Style["overflow"] = "hidden";
Line 244: cell.Style["text-overflow"
Line 245: cell.Style["Width"] = Unit.Pixel(100);
Line 246: }
Be aware, though, "text-overflow" only works in IE.
Create a style in your CSS like this:
.
.tbl
{
table-layout:fixed;
}
.tbl td
{
text-overflow:ellipsis;
overflow:hidden;
white-space:nowrap;
width:100px;
}
Then set GridView's CssClass = "tbl", and you are done. You don't need those code-behind code.
Create a style in your CSS like this:
.
.tbl
{
table-layout:fixed;
}
.tbl td
{
text-overflow:ellipsis;
overflow:hidden;
white-space:nowrap;
width:100px;
}
Then set GridView's CssClass = "tbl", and you are done. You don't need those code-behind code.
ASKER
text-overflow:ellipsis;
My CSS does not seem to like the above code?????
My CSS does not seem to like the above code?????
It is ok. Just try it.
ASKER
text-overflow is not accepted in CSS
ASKER
States text-overflow is not a know CSS name
Visual Studio does not recognize it does not mean the browser will not accept it. Did have have a chance to try it yet?
ASKER
The ellipsis is not working
1. It only works in IE.
2. Make sure you link the CSS file in your page.
3. The GridView has to have a fixed width.
2008-11-07-115649.jpg
2. Make sure you link the CSS file in your page.
3. The GridView has to have a fixed width.
2008-11-07-115649.jpg
ASKER
Yes, but look at the headings. They have been cut off. I would like the headings to be displaye din full and the data which you have highlighted in yellow to have ellipsis.
Regards,
introlux
Regards,
introlux
That is because the header text in my example is longer than 100px. If your header text is the same, then adjust the width in the style to accommodate it.
ASKER
So is there no way to put a word onto two lines? example:
Word: Have a great Day
This will normally be displayed like this in teh header:
Have a great Day
I would like it displayed like this:
Have a
Great Day
Any idea how this can be achieved??
Word: Have a great Day
This will normally be displayed like this in teh header:
Have a great Day
I would like it displayed like this:
Have a
Great Day
Any idea how this can be achieved??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have done this and still it does not do what I want it to do...............
>>>I have done this and still it does not do what I want it to do...............
It does not help me, man. You will need to be more specific about your problem.
It does not help me, man. You will need to be more specific about your problem.
ASKER
I would like it displayed like this:
Have a
Great Day <--------------------Does not display header like this even though I have done what you have said by using the CSS
Have a
Great Day <--------------------Does not display header like this even though I have done what you have said by using the CSS
It should wrap the text. Could you post your code?
ASKER
Forgot to post back, but this actually worked.
Thanks
Thanks
Have you try with this?
cell.Style["Width"] = Unit.Pixel(100);
However, you can check the width of each entered before set the preferred width to 100px.