Brent,
Don't create any columns before runtime. Then use the Repeater's
OnItemDatabound event (which fires as each row of the datasource is gone
through) to check which columns are present. Then you may dynamically add
the columns from there.
It may help you to see some code from my website that shows how to make a
datagrid's rows clickable.
Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
Try
Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or (itemType = ListItemType.Header) Or
(itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = CType(e.Item.Cells(3).Controls(0), LinkButton)
e.Item.Attributes("onClick") = Page.GetPostBackClientHyperlink(button, "")
e.Item.Attributes.Add("onMouseOver",
"javascript
:this.style.cursor='pointer';")
e.Item.Attributes.Add("omMouseOut",
"javascript
:this.style.cursor='normal';")
End If
Catch ex As Exception
Call ProcessError("There was an error setting up the datagrid.", ex)
End Try
End Sub
Note that "e" is the datagrid's row. The repeater's items will be accessed
similarly. Sorry, but I don't have any code that uses a repeater. But I'm
hoping this will give you some ideas and some keywords to google with.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Brent" <""b b i g l e r \"@ y a h o o . c o m"> wrote in message
news:11*************@corp.supernews.com...
My SQL might generate a result like this:
Security 2005-06-30 2005-03-31 2004-12-31
IBM $65 $100 $123
(etc)
or like this:
Security 2005-06-30 2005-03-31
IBM $65 $100
(etc)
In other words, I don't know the number of columns until runtime. This
presents a problem in my repeater logic.
In the past I might do something like this:
==========================
<asp:Repeater id="dl" runat="server" EnableViewState="false">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Security")
<%# DataBinder.Eval(Container.DataItem, "2005-06-30") %>
<%# DataBinder.Eval(Container.DataItem, "2005-03-31") %>
<%# DataBinder.Eval(Container.DataItem, "2005-12-31") %>
</ItemTemplate>
</asp:Repeater>
==========================
This repeater will fail, however, if I have more or fewer date columns
than indicated.
So, the question is: how do I specify the number of columns at runtime?
Can I do a loop inside my repeater somehow?
I'd sure appreciate any help!
--Brent