Thursday, February 4, 2010

HOW TO CREATE HTML TABLE USING STRING BUILDER ?

StringBuilder strBldr = new StringBuilder();
StringBuilder strFAQ = new StringBuilder();


strFAQ.Append("");


//for(int iTemp = 0 ;i< dsListOfFAQ.Tables[0].Rows.Count;i++)
int Counter = dsListOfFAQ.Tables[0].Rows.Count;

if (Counter > 0)
{
int count = 1;

foreach (DataRow dr in dsListOfFAQ.Tables[0].Rows)
{

//DataRow dr = dsListOfFAQ.Tables[0].NewRow();

strFAQ.Append("");

strFAQ.Append("");
strFAQ.Append("");
count += 1;

}
strFAQ.Append("
");
//strFAQ.Append( Convert.ToInt32(dr["FAQID"].ToString()) +".");
strFAQ.Append(Convert.ToInt32(dr["serial"].ToString()) + ".");

//divFAQList.InnerHtml += "
='"+ Convert.ToInt32(dr["FAQID"].ToString()) +"'>
";


strFAQ.Append("" + dr["Question"].ToString() + "");
//divFAQList.InnerHtml += "
";



strFAQ.Append("

");
strFAQ.Append(dr["Answer"].ToString());

if (count == dsListOfFAQ.Tables[0].Rows.Count)
{
strFAQ.Append("
");
strFAQ.Append("
");
}


strFAQ.Append("Click here

to Edit    ");
//strFAQ.Append(" " + "Approve    " + " ");
strFAQ.Append("Delete");

strFAQ.Append("

");

strFAQ.Append("
");
lblFAQ.Text = strFAQ.ToString();
}
else
{
lblFAQ.Text = "No record found.";
lblFAQ.ForeColor = System.Drawing.Color.Red;
lblFAQ.Font.Bold = true;
}
}

No comments:

Post a Comment