반복 무한급 분류 표시 실현
5451 단어 귀속
string html = "";
protected string GetClass(int ParentID,string TableName,string FileName)
{
SqlParameter sparm = new SqlParameter("@ParentID", SqlDbType.Int);
sparm.Value = ParentID;
SqlDataReader sdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, "SELECT * FROM " + TableName + " WHERE ParentID = @ParentID ORDER BY ClassID ASC",sparm);
if (sdr.HasRows)
{
html += "<ul>
";
}
while (sdr.Read())
{
html += "<li><a href=\""+FileName+"?ClassID=" + sdr[0].ToString() + "\">" + sdr["ClassName"].ToString() + "</a>
";
if (Convert.ToInt16(sdr["Child"]) > 0)
{
GetClass(Convert.ToInt16(sdr["ClassID"]),TableName,FileName); //
}
html += "</li>
";
}
if (sdr.HasRows)
{
html += "</ul>
";
}
return html;
}