Click here to Skip to main content
15,899,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I want to bind data to datasource to a repeater and this is my code.for each id i have to fetch details from database and show it on page using a repeater.

ds has only id for each id in ds i have fetch details from database.

whats happening in my code is only one record is given a datasource when i more than 10 how can give all 10 to a datasource? Please help.
C#
protected void repeater(DataSet ds)
        {
            logic.Admin adm = new logic.Admin();
            int rowCount = ds.Tables[0].Rows.Count;
            DataSet ds1=null;
            
            for (int intCount = 0; intCount < rowCount; intCount++)
            {
                string id = ds.Tables[0].Rows[intCount]["MUid"].ToString();

                 
                 ds1 = adm.getUserProfile(Convert.ToInt32(id));
                 
              }
            MyMentorRep.DataSource = ds1;
            MyMentorRep.DataBind();

        }
Posted
Updated 24-Jul-13 19:04pm
v2
Comments
Dholakiya Ankit 25-Jul-13 0:27am    
trt my solution tell me if not working
Jhone2011 25-Jul-13 3:02am    
1. use nested control concept,i mean create one more repeater in your first repeater, and at itembound event find another repeater and fill with respective ids, to find ids u can use hidden control.

one more thing i am not sure abt ur above code when ever u assign data to ds1 it will create new instance so i am thinking it will take last id data only

protected void repeater(DataSet ds)
        {
            logic.Admin adm = new logic.Admin();
            int rowCount = ds.Tables[0].Rows.Count;
            DataSet ds1=null;
            
            for (int intCount = 0; intCount < ds.Tables[0].Rows.Count; intCount++)
            {
                string id = ds.Tables[0].Rows[intCount]["MUid"].ToString();
 
                 
                 ds1 = adm.getUserProfile(Convert.ToInt32(id));
                 
              }
            MyMentorRep.DataSource = ds1;
            MyMentorRep.DataBind();
 
        }
 
Share this answer
 
add all the rows to one table returning from adm.getUserProfile(Convert.ToInt32(id)); and then add that table to dataset
then assign dataset to repeater as DataSource
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900