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

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;
....
 
G

Guest

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;
...
 
S

Scott Allen

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;
...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top