Creating Repeater control dynamically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

Is it possible to create the repeater control dynamically
I need to run a query and create repeator controls dynamically equal to no. of rows in the query

Any idea
I appreciate your help

Regards
Randall
 
Hi Randall, if I understand you correctly, the repeater *does* handle multiple rows, but you don't need to create multiple repeater controls. Just set the DataSource to your dataset/datatable, and provide an item template for how to render each row of data that you get. If there's more to it than that, please provide more info

----- Randall wrote: ----

Hi all

Is it possible to create the repeater control dynamically
I need to run a query and create repeator controls dynamically equal to no. of rows in the query

Any idea
I appreciate your help

Regards
Randall
 
Hi Randall, sorry, I'm just not getting it. Can you tell me in high-level (i.e. end user) terms what you're trying to accomplish, like the guy selects a category from a dropdown, you show some data, etc. I'm wondering if what you're trying to achieve is a grid-like thing where each row has a dropdown, and when you select that dropdown the rest of the row fills out in a format specific to that type of selection? Were that the case, you might want something other than a repeater.

----- Randall wrote: -----

Hi Bill,

Thanks for replying back to me.

Here is the scenario.

commandString1= " Select TC.CategoryID, T.TopicName, C.name from tblTopicsToCategories TC, viewTopics T , tblCategory C where TC.TopicID = T.TopicID and TC. Categoryid= C.CategoryId and T.TopicName = '"+CMSContext.Posting.DisplayName +"' ORDER BY TC.SortOrder";
connection.Open();

System.Data.SqlClient.SqlCommand command=new System.Data.SqlClient.SqlCommand(commandString1,connection);
SqlDataReader dataReader1 = command.ExecuteReader();

while (dataReader1.Read())
{
CategoryId=dataReader1.GetSqlInt32 (0).ToString ();
CategoryName=dataReader1.GetString(2);

commandString2 = "SELECT PC.categoryID , C.name , S.county, P.programTitle FROM tblSession S, tblProgram P, tblProgramCategory PC, tblCategory C WHERE S.programId = P.programId and P.programID = PC.programID and PC.categoryID = C.categoryID and county='montgomery' and C.CategoryId ='"+CategoryId+"

SqlDataAdapter dataAdapter= new SqlDataAdapter(commandString2,connectionString);
DataSet dataSet=new DataSet();
dataAdapter.Fill(dataSet,"tblSession");
DataTable dataTable= dataSet.Tables[0];
Repeater1.DataSource=dataTable;
Repeater1.DataBind();
}

What happens here that for each value from the first query I need to have a separate display but in this case it is overwritten because I am using one repeater control.

Any suggestion?
I appreciate your help.

Regards,
Randall
 
Hello Bill,

Thanks for replying back to me.

Okay the case is that based on some condition the first query returns some results with category id.
And for each row returnrd by the firast query I need to run the second query and display its output on the scrren Category wise.

I think it will help you to understand the requirement.
If you need any more info. please let me know.

Again, I appreciate your help.

Regards,
Randall
 
Back
Top