create and read variable amount of dropdownlists

Last post 07-25-2007 8:33 AM by Steven D. 0 replies.

Sort Posts:

  • create and read variable amount of dropdownlists

    07-25-2007, 8:33 AM
    • Loading...
    • Steven D
    • Joined on 07-25-2007, 8:02 AM
    • Belgium
    • Posts 2

    Hi, I'm new here - first post and all - and quite new to asp.net as well ... I have used this forum to find answers before, but this is the first time I can't find anything that seems even remotely the same. So I should just ask what's been bothering me for over a day now.

    I'm trying to create a variable amount of dropdownlists on a page (based upon the number of columns in a csv-file the user selects), give each one his own ID, bind 'em all to the same datasource and than have the user select an option in each dropdown. When the user does this and clicks on a button, the columns in the csv-file should be rearranged in the order chosen by the user in the dropdowns. Ex : when the csv contains 3 columns, there will be 3 dropdowns (ddl1,ddl2,ddl3) and the user can choose for instance the order 3,1,2. The columns should than be reordered this way.

    My problem is that even though I can check the number of columns, create the needed dropdowns, all databind 'em, I can not create a Select Case based upon the ID of those dropdowns. Execution just skips these cases. Probably because I actually have a String as 'attribute' for the Select Case. But there are no errors or warnings in VS2005. rest of file executes normally.

    I have set up the dropdowns by looping through the creation for one while a counter isn't equal to the number of columns read from the csv-file in the beginning. I give 'em an ID created by "ddl" & CStr(counter). When trying this in Select Case chosenddl (after setting Dim chosenddl As String = "ddl" & CStr(counter) of course), nothing happens.

    Is there a solution ? Should I do this whole thing in another way ?

    *** EDITed below ...

    Got some info and turned the whole process upside down. As I will always be using the same stored procedure to import data after re-arranging the order of their columns, it seemed handier to create a set number of dropdowns (as many as variables in the stored procedure) and fill them with the content of the first row in the csv-file. Thus re-arranging the columns according to the set order of variables from the stored procedure. Set value of dropdown one to match the name of the variable from the stored procedure ... Instead of displaying the values of the first row and choose the matching variable from the stored procedure in the dropdownlist. That way I bypass all possible errors with the names of the dropdownlists as I can now set them directly. Makes using Select Case possible again.

    Should anyone have another idea based on original post, or on the 'workaround' feel free to leave it here ...

Page 1 of 1 (1 items)
Microsoft Communities
Page view counter