0

I'm designing a website for my FYP, i have an customerOrder page, and a viewOrders page, customer places order in CustomerOrder page. in viewOrders i want to display the result of sql query, in dynamically created "div" and "labels" with CSS assigned to them for each row of table, in following SqlDataReader.tnx

protected void Page_Load(object sender, EventArgs e)
    {

        string localCnnString =
        ConfigurationManager.ConnectionStrings["LGDB"].ToString();
        SqlConnection SqlCnn = new SqlConnection(localCnnString);

        SqlCommand SqlCmd = new SqlCommand();

        SqlDataReader dReader;

        SqlCnn.Open();
        SqlCmd.Connection = SqlCnn;
        SqlCmd.CommandType = CommandType.StoredProcedure;

        SqlCmd.CommandText = "myrpoc";

        dReader = SqlCmd.ExecuteReader();

        while (dReader.Read())
        {
            //dynamic controls

        }

        dReader.Close();
        SqlCnn.Close();

    }
}
1

2 Answers 2

2

This scenario can be solved in many different ways. The general approach though is some sort of data binding. If you're doing web forms I would look into the Repeater control, which will offer good template based data binding.

A less elegant way is to just loop out some dynamic html.

Sign up to request clarification or add additional context in comments.

Comments

0

you can use data binding approach for Repeater or Gridview or Datalist.

another way is by string building for dynamic html and using it in divContent.InnerHtml

HTML

<div id="divContent" runat="server">

</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.