jeenath kumar

jeenath kumar

  • 1.7k
  • 64
  • 3.7k

how to dynamically using repeater control

Aug 22 2019 2:56 AM
Hi...
 
i had a table
 
 sno  title  query
 1  Total Customer  select isnull(sum(cus_id),0) from customer
 2  Total Products  select isnull(sum(prod_id),0) from product
 
what i tried
 
in .aspx
  1. <asp:Repeater ID="rtrDashboard" runat="server">  
  2. <ItemTemplate>  
  3. <div class="col-lg-3">  
  4. <div class="test">  
  5. <h4>  
  6. <%#Eval("title")%></h4>  
  7. <br />  
  8. <p>  
  9. <asp:Label ID="lblvalue" runat="server" Text='<%#Eval("query")%>'></asp:Label>  
  10. </p>  
  11. </div>  
  12. </div>  
  13. </ItemTemplate>  
  14. </asp:Repeater>  
in aspx.cs
  1. public void bindrepeater()  
  2. {  
  3. using (SqlConnection con = new SqlConnection(constr))  
  4. {  
  5. DataTable dt = new DataTable();  
  6. try  
  7. {  
  8. con.Open();  
  9. SqlCommand cmd = new SqlCommand("select * from DashBoard order by dash_order", con);  
  10. DataSet ds = new DataSet();  
  11. SqlDataAdapter da = new SqlDataAdapter(cmd);  
  12. da.Fill(ds);  
  13. dt = ds.Tables[0];  
  14. rtrDashboard.DataSource = dt;  
  15. rtrDashboard.DataBind();  
  16. }  
  17. catch (Exception ex)  
  18. {  
  19. ex.Message.ToString();  
  20. }  
  21. finally  
  22. {  
  23. con.Close();  
  24. }  
  25. }  
  26. }  
i don't know how to execute 3rd column query and set the value in label

Answers (5)