Results 1 to 5 of 5

Thread: forum****

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    194

    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!
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: forum****

    Can you rephrase your question more clearly? I was able to follow the question halfway, then got lost.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    194

    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!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    194

    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!

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: forum****

    Glad you got it. *Sigh of Relief*

    http://www.vbforums.com/showthread.p...light=treeview

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width