how to bind datalist to dynamicaly generated user control

Posted by RohiK under Regular Expressions on 8/17/2010 | Points: 10 | Views : 2969 | Status : [Member] | Replies : 2
Hi to all,

I wanted to add usercontrol in my page but dyanamicaly so I am adding it by
UserControl uc=new UserControl ();
method
then i want to bind datalist to that control ...
how to do that one?

plz help

Happy Programming!!
Rohi



Responses

Posted by: Raja on: 8/18/2010 [Member] Starter | Points: 25

Up
0
Down
Do your DataList exists in the UserControl? If yes, you can find and bind it something like this.

DataList dlist = (DataList) uc.FindControl("DataList1");

dlist.DataSource = "Your datasource";
dlist.DataBind();


I hope this helps

Regards,
Raja, USA

RohiK, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RohiK on: 8/19/2010 [Member] Starter | Points: 25

Up
0
Down
Thanks for reply.

Actually I want to do little different.
firstly i wnat to generate datalist in first user control let us consider it will display product names
and when user click on any product then another usercontrol will display product attributes.

it means i want to display like -
first usercontrol
product1
product2
product3

and when user click on product 1 it will display

product 1
attribute1
attribute2
product2
product3



I am doing this by using accordion. so i am binding products into <li><a>product1</a></li> tag
and it is in code behind page and i am using that product id to display it's attributes
by using simple another <li> tags it is simple but i want to display options in another user control.

i have created it but how to place it in between these <li></li> on codebehind page..?


plz help!!!



Happy Programming!!
Rohi

RohiK, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response