Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 13th, 2006, 04:40 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default Callback in 3 DropDownLists

Hi ,
i read data to 3 combos - 2 of them depend on other . I don't know how to do another callback to the third DDL - it causes some problems.

  #2 (permalink)  
Old December 13th, 2006, 08:20 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. do you have some code?? or any specific problem???

HTH

Gonzalo
  #3 (permalink)  
Old December 13th, 2006, 08:47 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ,
here is the javascript code in .aspx file :
   <script language="javascript">
   function ClientCallback(result, context){

      var childOrganizations = document.forms[0].elements[
            '<%=ddlSubCat.UniqueID%>'];

      if (!childOrganizations){
         return;
      }
      childOrganizations.length = 0;
      if (!result){
         return;
      }
      grp = result.split("~")[1];
      result = result.split("~")[0];
      var rows = result.split('|');
      for (var i = 0; i < rows.length; ++i){

         var values = rows[i].split('^');
         var option = document.createElement("OPTION");
         option.value = values[0];
         option.innerHTML = values[1];
         if (option != undefined && values[1] != undefined && values[0] != undefined) {
         childOrganizations.appendChild(option);
         }
        //childOrganizations.options.add(option , i);
      }
       var childGrp = document.forms[0].elements[
       '<%=ddlGroup.UniqueID%>'];
       childGrp.length = 0;
       var rows1 = grp.split('|');
       for (var j = 0; j < rows1.length; ++j){
         var values1 = rows1[j].split('^');
         var option1 = document.createElement("OPTION");
         option1.value = values1[0];
         option1.innerHTML = values1[1];
         if (option1 != undefined && values1[1] != undefined && values1[0] != undefined) {
         childGrp.appendChild(option1);
         }
      }


   }

      function ClientCallback1(result, context){

       var childGrp = document.forms[0].elements[
       '<%=ddlGroup.UniqueID%>'];
       childGrp.length = 0;
       var rows1 = result.split('|');
       for (var j = 0; j < rows1.length; ++j){
         var values1 = rows1[j].split('^');
         var option1 = document.createElement("OPTION");
         option1.value = values1[0];
         option1.innerHTML = values1[1];
         if (option1 != undefined && values1[1] != undefined && values1[0] != undefined) {
         childGrp.appendChild(option1);
         }
        //childOrganizations.options.add(option , i);
      }

   }

   function GetChildren(arg, context)
   {

   <%= callBack %>
    }

      function GetSubChildren(arg, context)
   {

   <%= callBack1 %>
   }
   </script>


AND here is part of the .aspx.cs file code :
public partial class BookPhone : System.Web.UI.Page , ICallbackEventHandler
{
    public string callBack , callBack1;
    public int choice = 1;
    int arg = 0 , arg3 = 0 ;

    protected void Page_Load(object sender, EventArgs e)
    {


        //Response.Write("<script language='JavaScript'>alert('" + Request.Cookies["PUID"].Value + "');</script>");
        /*if (Request.Cookies["PUID"] == null || Request.Cookies["PUID"].Value.Trim().Equals(""))
        {
            Response.Redirect("default.aspx");
        }
        if (!new UserOwnBooksController().IsUserOwnsBooks(Request.C ookies["PUID"].Value , TryParse(Request.QueryString["BID"])))
        {
            Response.Redirect("default.aspx");
        }*/
        DataRow dr = new BooksController().GetSpecificBook(int.Parse(Reques t.QueryString["BID"]));
            lblCount2.Text = new PhoneController().GetNumOfRecords(int.Parse(Reques t.QueryString["BID"])).ToString();
        //imgPrint1.OnClientClick = "OpenPopUp('" + Request.QueryString["BID"] + "' , '" + txtSearchWords.Text.Trim() + "' , '" + ddlCat111.SelectedValue + "' , '" + ddlSubCat111.SelectedValue + "' , '" + ddlGroup111.SelectedValue + "');";
            imgPrint1.PostBackUrl = "PrintScreen.aspx?BID=" + Request.QueryString["BID"] + "&KID=" + txtSearchWords.Text.Trim() + "&CatID=" + ddlCat111.SelectedValue + "&SID=" + ddlSubCat111.SelectedValue + "&GID=" + ddlGroup111.SelectedValue + "";
        if (!Page.IsPostBack)
        {
            PopulateBirthDate();
            PopulateSearch();


        }
        if (dr != null)
        {
            lblHeader1.Text = dr[1].ToString();
        }
        foreach (GridViewRow gr in GridView1.Rows) {
            DataRow dr1 = new PhoneController().GetSpecificRow(TryParse(Request. QueryString["BID"]));
        if (dr1 != null)
        {
            gr.ForeColor = System.Drawing.Color.FromName(dr1[26].ToString());
            gr.Font.Size = new FontUnit(dr1[25].ToString());
            gr.Font.Name = dr1[24].ToString();
        }
        }

        callBack = Page.ClientScript.GetCallbackEventReference(this, "arg" , "ClientCallback", "context");
        callBack1 = Page.ClientScript.GetCallbackEventReference(this, "arg", "ClientCallback1", "context");

        ddlCat.Attributes.Add("onchange", "GetChildren(this.options[this.selectedIndex].value, 'ddlSubCat');");
        ddlSubCat.Attributes.Add("onchange", "GetSubChildren(this.options[this.selectedIndex].value , 'ddlGroup')");

    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        if (choice == 1)
        {
            int parentId;

            if (Int32.TryParse(eventArgument, out parentId))
            {
                int firstNum = -1000;
                DataTable dt = new BSubCatsController().GetSubCatsByBookAndCat(int.Pa rse(Request.QueryString["BID"]), int.Parse(eventArgument));
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < dt.Rows.Count; ++i)
                {
                    sb.Append(dt.Rows[i]["SubCatID"]);
                    sb.Append("^");
                    sb.Append(dt.Rows[i]["SubCatDescription"]);
                    sb.Append("|");
                    if (firstNum == -1000)
                    {
                        firstNum = (int)dt.Rows[i]["SubCatID"];
                    }
                }
                sb.Append("~");
                arg = int.Parse(eventArgument);
                DataTable dt1 = new BGroupsController().GetGroupByBookCatAndSubCat(int .Parse(Request.QueryString["BID"]), arg, firstNum);
                foreach (DataRow dr1 in dt1.Rows)
                {
                    sb.Append(dr1["GroupID"]);
                    sb.Append("^");
                    sb.Append(dr1["GroupDesc"]);
                    sb.Append("|");
                }

            }
        }
        else if (choice == 2)
        {
            StringBuilder sb1 = new StringBuilder();
            arg3 = int.Parse(eventArgument);
            int theNum = arg3 ;
            DataTable dt3 = new BGroupsController().GetGroupByBookCatAndSubCat(int .Parse(Request.QueryString["BID"]), arg, theNum);

            foreach (DataRow dr3 in dt3.Rows)
            {
                sb1.Append(dr3["GroupID"]);
                sb1.Append("^");
                sb1.Append(dr3["GroupDesc"]);
                sb1.Append("|");
            }
        }
    }


    public string GetCallbackResult()
    {
        if (choice == 1)
        {
            int firstNum = -1000;
            DataTable dt = new BSubCatsController().GetSubCatsByBookAndCat(int.Pa rse(Request.QueryString["BID"]), arg);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                sb.Append(dt.Rows[i]["SubCatID"]);
                sb.Append("^");
                sb.Append(dt.Rows[i]["SubCatDescription"]);
                sb.Append("|");
                if (firstNum == -1000)
                {
                    firstNum = (int)dt.Rows[i]["SubCatID"];
                }
            }
            sb.Append("~");
            DataTable dt1 = new BGroupsController().GetGroupByBookCatAndSubCat(int .Parse(Request.QueryString["BID"]), arg, firstNum);
            foreach (DataRow dr1 in dt1.Rows)
            {
                sb.Append(dr1["GroupID"]);
                sb.Append("^");
                sb.Append(dr1["GroupDesc"]);
                sb.Append("|");
            }
            return sb.ToString();
        }
        else if (choice == 2)
        {

            StringBuilder sb1 = new StringBuilder();
            DataTable dt3 = new BGroupsController().GetGroupByBookCatAndSubCat(int .Parse(Request.QueryString["BID"]), arg, arg3);
            foreach (DataRow dr3 in dt3.Rows)
            {
                sb1.Append(dr3["GroupID"]);
                sb1.Append("^");
                sb1.Append(dr3["GroupDesc"]);
                sb1.Append("|");
            }
            return sb1.ToString();

        }
        return "";

    }

if this code is not sufficient - i'll send you the files to email.


  #4 (permalink)  
Old December 13th, 2006, 08:53 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

i don't have a clue about js, sorry...

you are doing the callbacks with js?

HTH

Gonzalo
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdownlists in DetailsView irelandk BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 20th, 2007 10:13 AM
Databinding 3 Dropdownlists rit01 ASP.NET 2.0 Basics 1 May 30th, 2006 10:47 AM
Creating "chain" of DropDownLists DolphinBay ASP.NET 1.0 and 1.1 Professional 0 December 2nd, 2005 07:45 PM
DropDownLists venterjo General .NET 1 January 8th, 2005 09:10 AM



All times are GMT -4. The time now is 04:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.