Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Selden McCabe #1
Header Text disappears when setting SortExpression
I have a datagrid that I want to set the column header text, column width,
bound data field, and sortexpression in code at run time.
This was working fine until I added the sortexpression, at which point the
headers disappeared!
Here is the code:
Private Sub AddColumn(ByVal sHeader As String, ByVal sDataColumn As String,
ByVal nWidth As Integer)
Dim bc1 As New BoundColumn
bc1.SortExpression = sDataColumn
bc1.DataField = sDataColumn
bc1.HeaderText = sHeader
bc1.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(nWidth)
bc1.ItemStyle.Width = System.Web.UI.WebControls.Unit.Pixel(nWidth)
DataGrid1.Columns.Add(bc1)
End Sub
On the page_load, I do a bunch fo AddColumns, then generate a dataview with
the data, and bind it to the grid.
If I comment out the line that sets the SortExpression, the grid looks
great. If I add it back in, the header collapses to a couple of pixels
tall.
I've tried moving the SortExpression = line around, and even setting the
header text AFTER the grid gets databound, but none of these had any effect.
What am I doing wrong? Any suggestions would be very welcome!
Thanks,
---Selden
Selden McCabe Guest
-
text disappears
I used Contribute to edit two small sites of mine. One of them works fine so I know this program is working but with the other it doesn't work. The... -
Setting the SOAP header value?
Hi, I'm using .NET 1.1 and Visual Studio 2003. I just want understand something on setting the SOAP headers in a client app. At... ... -
Static Text Disappears
Wow.. the problem I have is pretty weird. I even scanned the whole computer for viruses because I couldn't believe what was happening. Here's... -
[PHP] setting header() for csv file
Hi again -- ...and then David T-G said... % ... % How do I construct the headers so that the browser says "Oh, this is a It turns out that... -
Text disappears when sized over 14
Sometimes the text in a text box cannot be seen (on stage) when the font is sized 14 or over. I know the text is still there as when I click on... -
Selden McCabe #2
Re: Header Text disappears when setting SortExpression
Here is some additional information that seems to bear on this:
I also want some of the column headers to have two rows. The way I
accomplished this was to insert %p% in the text where I want a line break.
Then, in the ItemDataBound event, for headers, Items, and AlternatingItems,
I replace %p% with <br>.
If I comment out that event, and set the sortexpression, I see my text in
the headers.
So maybe my question should be more like, how can I control the number of
lines of text in the header, with AllowSorting=True?
---Selden
Selden McCabe Guest
-
Selden McCabe #3
Re: Header Text disappears when setting SortExpression
Now I feel really stupid!
After that last post, I thought about it some more, and realized that, with
the link that the sort creates, just adding <br> in the string wasn't
correct HTML syntax.
Now I use "<p>First Line<br>Second Line</p>" for the header text, and
everything works!
Selden McCabe Guest
-
Ken Cox [Microsoft MVP] #4
Re: Header Text disappears when setting SortExpression
Just enjoying watching you discuss this with yourself! <grin>
"Selden McCabe" <smccabe@integrantInc.com> wrote in message
news:%23jqjNolgEHA.1184@TK2MSFTNGP12.phx.gbl...> Now I feel really stupid!
> After that last post, I thought about it some more, and realized that,
> with
> the link that the sort creates, just adding <br> in the string wasn't
> correct HTML syntax.
> Now I use "<p>First Line<br>Second Line</p>" for the header text, and
> everything works!
>
>Ken Cox [Microsoft MVP] Guest
-
Selden McCabe #5
Re: Header Text disappears when setting SortExpression
Hi Ken, Glad to provide some entertainment! <g>
Selden McCabe Guest



Reply With Quote

