グーグルをウォーミングアップし、アイデアを実装した後、私はこれに魂を注ぎました。コードビハインドにhtmlコントロールを追加し、プレースホルダーに配置するだけで問題が解決します。Page_Loadメソッドのコードを参照してください。
.ASPX
<div>
<asp:placeholder runat="server" id="placeholderDynamic">
</asp:placeholder>
</div>
.ASPX.CS
if (!IsPostBack)
{
// Get the list from database
List<CategoryQuesAns> quesAns = GetQuestions();
//For Jquery tabs we require <li> in <ul> and <div> within one outer <div>
//Create outer div
HtmlGenericControl divCotnainer = new HtmlGenericControl("div");
divCotnainer.ID = "ui-tabs";
divCotnainer.ClientIDMode = ClientIDMode.Static;
//Create ul
HtmlGenericControl unorderdList = new HtmlGenericControl("ul");
//Create li's as per the number of questions
int i = 1;
foreach (CategoryQuesAns ques in quesAns)
{
HtmlGenericControl listcontrol = new HtmlGenericControl("li");
HtmlAnchor anchor = new HtmlAnchor();
anchor.HRef = "#tabs-"+i.ToString();
anchor.InnerText = "Q-" + i.ToString();
listcontrol.Controls.Add(anchor);
//adding li in ul
unorderdList.Controls.Add(listcontrol);
i++;
}
//adding ul in the outer div
divCotnainer.Controls.Add(unorderdList);
//adding div in the outer div
int j = 1;
foreach (CategoryQuesAns ques in quesAns)
{
//create inner div as per the number of questions
HtmlGenericControl divtabs = new HtmlGenericControl("div");
divtabs.ID = "tabs-" + j.ToString();
divtabs.ClientIDMode = ClientIDMode.Static;
//create gridview table for each tab(li)
Label lblQuestionText = new Label();
lblQuestionText.Text = ques.QuestonName;
GridView dyamicGrid=new GridView();
dyamicGrid.ID = "Gridview-" + j.ToString();
dyamicGrid.ClientIDMode = ClientIDMode.Static;
dyamicGrid.CssClass = "mGrid";
dyamicGrid.DataSource = quesAns;
dyamicGrid.DataBind();
divtabs.Controls.Add(lblQuestionText);
divtabs.Controls.Add(dyamicGrid);
divCotnainer.Controls.Add(divtabs);
placeholderDynamic.Controls.Add(divCotnainer);
j++;
}
}