-
1 Attachment(s)
forum****
I try to built a forum
in the DB its like the attach file
if the fid = 0 thats mean its a new message
if the fid > 0 thats mean is answer to message
i thout how to do it
do 1 data table that take all the message that the fID = 0
and bind grid view
in the grid view make item tamplate that call to recursive function to show the suns message.
I want idea how to take the suns message
thanks!
-
Re: forum****
Can you rephrase your question more clearly? I was able to follow the question halfway, then got lost. :(
-
Re: forum****
mendhak
I sure you can help me,
and I know that my english hard to understand
now I just in the begining.
I want to built forum like tree
father1
son 1
grandson
son 2
grandson
grandson
I take all the father message
and insert into grid view
here the exapmle http://212.199.43.15/forum/showmessage.aspx
now the hard part is to take the sons and the greandsons etc'
here I need a recursive function.
I try write this:
Code:
}
protected string ShowSun(string mid)
{
string h = "";
string strSQL;
strSQL = "select * from forum where fID = " + mid;
OleDbConnection cn = new OleDbConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
cn.Open();
OleDbDataReader reader;
cmd.Connection = cn;
cmd.CommandText = strSQL;
reader = cmd.ExecuteReader();
while (reader.Read())
{
h += "<BR>" + reader["subject"].ToString();
h += "ShowSun(" + reader["mid"].ToString() + ")";
ShowSun(reader["mid"].ToString());
}
return h;
}
and in the grid view I call the function:
Code:
<%# ShowSun(Eval("mID").ToString())%>
but this function doesnt work, it take just the sons and not the grandsons.
if you have an idea how to fix it, or another way to do it,
it will help me so much
thanks!
-
Re: forum****
ok thanks I got it:
protected string ShowSun(string mid)
{
StringBuilder sb = new StringBuilder();
recurcive(mid, ref sb,0);
return sb.ToString();
}
protected void recurcive(string mid, ref StringBuilder sb, int t)
{
++t;
DataRow[] selectedRows = ds.Tables["sID"].Select(string.Format("fID={0}", mid));
for (int i = 0; i <= selectedRows.GetUpperBound(0); ++i)
{
sb.Append("<BR />");
sb.Append(selectedRows[i]["subject"].ToString());
sb.Append(t.ToString());
recurcive(selectedRows[i]["mid"].ToString(), ref sb,t);
}
}
thanks!
-
Re: forum****