how to use string variable to for datalist name to bind with

N

nnet

I have the following
1. string[] tabname={"xx", "yy"}
2. two datalist in my .aspx page named xx and yy
3. in my .cs page inside page_load() the following line

string name = tabname[0];

name.DataSource = reader
name.DataBind();

I get an error indicating that name is not representing any datalist.
I guess some how I need to tell it that name is not only a variable
it is a existing data list in the .aspx file.

any idea how to do it.

Thanks
 
A

Aravind C

Hi nnet,

I guess you need to probably store the DataList instances
in a hashtable that are indexed by the names, for
example 'xx' and 'yy' in your example.
Based on the name, you can then obtain the desired DataList
instance from the Hashtable and call its methods/properties.

DataList xx = (DataList)myHashTable["xx"]
xx.DataSource = ...;
xx.DataBind();

Regards,
Aravind C


nnet said:
I have the following
1. string[] tabname={"xx", "yy"}
2. two datalist in my .aspx page named xx and yy
3. in my .cs page inside page_load() the following line

string name = tabname[0];

name.DataSource = reader
name.DataBind();

I get an error indicating that name is not representing any datalist.
I guess some how I need to tell it that name is not only a variable
it is a existing data list in the .aspx file.

any idea how to do it.

Thanks



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 

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

Top