Appending values into dropdown list - InfoPath Dev
in

InfoPath Dev

Appending values into dropdown list

Last post 03-26-2007 12:34 AM by anandhienator. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-21-2007 06:04 AM

    Appending values into dropdown list

    Hi All,

    I want to add values into the dropdownlist present on the infopath form at run time thru managed code. How can i do so ? I tried cloning the root and then appending the new child to the root. The code snippet is as follows :

    while (rdr.Read())//read through rows
    {
    sqlConnection2.Open();
    string T_Id = rdr[2].ToString();
    string cmdTxt = "select distinct TaskId,TaskName from MainTaskTB where TaskId=" + T_Id + " order by TaskId";

    cmd = new SqlCommand(cmdTxt);
    cmd.Connection = sqlConnection2;

    rdr1 = cmd.ExecuteReader();
    while (rdr1.Read())
    {
    temp = root.Clone();
    temp2 = temp;

    temp3 = temp2.SelectSingleNode("/my:myFields/my:WorkAssignedDetails/my:MainTask", this.NamespaceManager);
    DeleteNil(temp3);
    temp3.SetValue(rdr1[1].ToString());

    }
    //temp.AppendChild(temp2);
    temp.InsertAfter(temp2);
    }
    root.DeleteSelf();

    I am getting an error after the "temp.InsertAfter(temp2)" saying that "Schema validation has non-datatype errors". For this, infopath team blogs gave me a solution saying to add a function called "DeleteNil(paramater)". I did that too but still facing the same error.

    Awaiting reply soon.
    Regards,
    Anandhi
  • 03-22-2007 09:50 AM In reply to

    Re: Appending values into dropdown list

    Hi Anandhi,

    Check out these HowTos:
    http://infopathdev.com/howto/tutorials/default.aspx?s=Lists

    Specifically this one:
    Populate a Drop-Down List Box via Code
    http://infopathdev.com/howto/tutorials/default.aspx?i=987250af134b4ced85cbddc7db724202
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-26-2007 12:34 AM In reply to

    Re: Appending values into dropdown list

    Hi Matt,

    I checked out the article named "Populate a Drop-Down List Box via code." Well.. I tried the example and it worked. But the only problem is that, even though the values could be seen by the user into the dropdown, the user is unable to see the selected value. After the user selects the value he is interested in, user sees a blank only...

    Please help. :)
    Regards,
    Anandhi
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.