C# Databinder.Eval didn't work quite right...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm following

http://msdn.microsoft.com/library/d...atingwebservercontroltemplatesdynamically.asp

Why did I have to use this in the event handler?

lc.Text += "<td align=\"left\">" +
((System.Data.DataRow)(((System.Data.DataRowView)(((System.Object)(container.DataItem)))).Row)).ItemArray[0].ToString() + "</td>";

I could never get lc.Text to use DataBinder.Eval on the columns.

code:
....
case ListItemType.Item:
lc.Text = "<tr style=\"background-color:#F0F0F0\">";

lc.DataBinding +=new EventHandler(lc_DataBinding);
break;
case ListItemType.AlternatingItem:
lc.Text = "<tr style=\"background-color:#E0E0E0\">";
lc.DataBinding +=new EventHandler(lc_DataBinding);

break;
case ListItemType.Footer:
lc.Text = "</table>";
break;
....
 
By extending ITemplate, like in the link I refer to in the initial post

Scott Allen said:
Hi Eskimo:

How were you using lc.Text in ASPX?
Here is an article that might help:

Digging Into Data Binding Expressions
http://odetocode.com/Articles/278.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

Hi,

I'm following

http://msdn.microsoft.com/library/d...atingwebservercontroltemplatesdynamically.asp

Why did I have to use this in the event handler?

lc.Text += "<td align=\"left\">" +
((System.Data.DataRow)(((System.Data.DataRowView)(((System.Object)(container.DataItem)))).Row)).ItemArray[0].ToString() + "</td>";

I could never get lc.Text to use DataBinder.Eval on the columns.

code:
...
case ListItemType.Item:
lc.Text = "<tr style=\"background-color:#F0F0F0\">";

lc.DataBinding +=new EventHandler(lc_DataBinding);
break;
case ListItemType.AlternatingItem:
lc.Text = "<tr style=\"background-color:#E0E0E0\">";
lc.DataBinding +=new EventHandler(lc_DataBinding);

break;
case ListItemType.Footer:
lc.Text = "</table>";
break;
...
 
Yes, Eskimo, I did look at the article, but I still don't know what
the rest of your code looks like. I wasn't sure if you were
complaining about the ugliness of the casting expressions or something
not working with data binding.

--
Scott
http://www.OdeToCode.com/blogs/scott/


By extending ITemplate, like in the link I refer to in the initial post

Scott Allen said:
Hi Eskimo:

How were you using lc.Text in ASPX?
Here is an article that might help:

Digging Into Data Binding Expressions
http://odetocode.com/Articles/278.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

Hi,

I'm following

http://msdn.microsoft.com/library/d...atingwebservercontroltemplatesdynamically.asp

Why did I have to use this in the event handler?

lc.Text += "<td align=\"left\">" +
((System.Data.DataRow)(((System.Data.DataRowView)(((System.Object)(container.DataItem)))).Row)).ItemArray[0].ToString() + "</td>";

I could never get lc.Text to use DataBinder.Eval on the columns.

code:
...
case ListItemType.Item:
lc.Text = "<tr style=\"background-color:#F0F0F0\">";

lc.DataBinding +=new EventHandler(lc_DataBinding);
break;
case ListItemType.AlternatingItem:
lc.Text = "<tr style=\"background-color:#E0E0E0\">";
lc.DataBinding +=new EventHandler(lc_DataBinding);

break;
case ListItemType.Footer:
lc.Text = "</table>";
break;
...
 
Back
Top