in

InfoPath Dev

Programmatically populate a Drop-Down List Box

Last post 10-01-2008 11:16 PM by Shiva. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-28-2007 09:32 AM

    Programmatically populate a Drop-Down List Box

    Hello,

    I am trying to populate a Drop-Down List Box with values I receive from an ADO.NET connection behind InfoPath.  I am hitting a Stored Proc with 4 parameters and will received back a list of numbers, I would like those number to populate my Drop-Down List Box.  Depending on what view I'm at those parameters will change and so will the list of numbers.  Any advice would be far beyond appreciated at this point!

    Thank you:)

    Filed under: ,
  • 11-28-2007 02:23 PM In reply to

    Re: Programmatically populate a Drop-Down List Box

    First step would be to verify your data connection is performing properly.

    Are you setting up your Data Connection in InfoPath or doing it behind in code?

    In the InfoPath UI you would just det the dropdown to use the secondary data connection. You would need to requery oviously to get the data updated as you needed.

    I have not configured a drop down control in code.

  • 11-28-2007 02:44 PM In reply to

    Re: Programmatically populate a Drop-Down List Box

    Clay,

    My data connection is working properly because I can use the same stored proc with different parameters to fill textboxes.

    Everything I am doing is behind in code...I'm using ADO.NET (C#) a sqlDataReader to read in the data.

    I would use the InfoPath UI to set the values of the dropdown, but I need it to be dynamic as possible, and I don't want to hard-code the parameters in the 'edit sql' of the data connection.  If there is a way to pass a value from the form to the 'edit sql' in the data connection wizard that would solve my problem.

    Thank you for the response Clay...you're awesome!!

  • 10-01-2008 11:16 PM In reply to

    • Shiva
    • Top 10 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 602

    Re: Programmatically populate a Drop-Down List Box

    Hello,

    We can pass the parameters to stored procedure using code as below,

    SqlCommand sqlCommand = new SqlCommand("Stroed Procedure Name", sqlConnection);

    sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

    sqlCommand.Parameters.Add(sqlParameter);

Page 1 of 1 (4 items)
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.