Last post Jul 06, 2012 10:04 PM by Decker Dong - MSFT
Jul 05, 2012 05:01 PM|airic82|LINK
I think I'm having a simple issue, but could use some help with how to fix it.
I'm creating a custom web control in my App_Code section (it's inheriting WebControl). In it, I have a Repeater object that is the basis of the control.
I've overriden the Render method with this:
protected override void Render(HtmlTextWriter writer)
/* SET SOME ATTRIBUTES FOR REPEATER */
The repeater always renders like no data is returned, but it should be returning one item.
I know it's not the settings of the repeater (I've created the repeater with the same settings on a page and it renders correctly). So now I'm wondering if it has to do with where I'm setting the attributes. I've tried setting them by overriding the OnInit
and OnDataBinding methods, but that didn't help either.
Could someone please help me?
Jul 05, 2012 05:15 PM|AWAlger|LINK
Have you put a break point there onRender to make sure something isn't causing it to fire more than once? Also can you confirm the writer property that is being sent to it has a value in that render method also. i'm just wondering if something isn't setting
the datasource properly. Or to late. Override the ondatabinding and put something like string s = string.Empty. Then put a breakpoint there just to confirm that it's even binding right and only once.
Coding is like life, learn from the past and work towards the future, trying to redo past code, ends in lost time and nothing new accomplished.
Jul 05, 2012 05:22 PM|airic82|LINK
Well the repeater is a custom control from our CMS. It allows us to specify text to display if Zero Rows are returned. The control consistantly displays that text, so I know the control is rendering. It's more that it's not rendering properly because it's
not getting the data from the database.
I've already emailed their support techs, but I was wondering if someone here had any ideas that might help.
Since this is the first time I've created a custom control this way, I figured I was not assigning the properties at the correct time.
Jul 05, 2012 05:30 PM|AWAlger|LINK
Usually to assing the datasource it's just like the regular control
so if your class
public class repeat : Web.UI.Controls.Repeater (thats a guess on where it's found)
is all you had done. then all you would need to do is assign it like you normally do.
It shouldn't require any crazy code as long as the base is the control
the only thing you need to be doing differently is override where it shows the repeater and show a label instead.
Jul 06, 2012 10:04 PM|Decker Dong - MSFT|LINK
The repeater always renders like no data is returned,
Have you save the Data contents in the ViewState or Session？You should know that without doing this，Html is of non-memorization……