Selected value in asp.net dropdown in a repeater not returned

I've currently go a very strange problem. I'm using an asp.net wizard to upload some files. The files are uploaded using plupload. After the files have uploaded I have a list of the upload files stored in a session variable. I use the session variable to create a table showing the upload files. The user now has option to set a file category using a dropdown in the table. When the user clicks 'finish' button the code reads the list of files and the category from the table. The odd thing is this code works fine on my development machine and on several servers but on a particular clients server the drop down value always returns as null. Here is the relevent code:

protected void Page_Init(object sender, EventArgs e)
    {
            bindRepeater();         
    } 

private void bindRepeater()
    {
        ArrayList sessionFiles = (ArrayList)Session["PLUploadFiles"];

        IList<document> files = new List<document>();

        foreach (string fileName in sessionFiles)
        {
            document doc = new document();

            doc.FileName = fileName;
            doc.Description = fileName.Split('.').First();

            files.Add(doc);
        }

        TableRepeater.DataSource = files;
        TableRepeater.DataBind();
    }

protected void SaveButton_Click(object sender, EventArgs e)
    {

        foreach (RepeaterItem item in TableRepeater.Items)
        {
            Label descriptionLabel = (Label) item.FindControl("DescriptionLabel");
            String description = descriptionLabel.Text;

            Label fileNameLabel = (Label)item.FindControl("FileNameLabel");
            String fileName = fileNameLabel.Text;

            DropDownList categoryDropDown = (DropDownList) item.FindControl("CategoryDropDownList");
            string category = categoryDropDown.SelectedValue;

            if(SaveClicked != null)
            {
                SaveEventArgs s = new SaveEventArgs();
                s.FileName = fileName;
                s.Category = category;
                s.Description = description;

                SaveClicked(this, s);
            }

        }

        Response.Redirect(RedirectURL);
    }

Note that the entire wizard lives on a usercontrol. Has anybody got any idea why this code works fine on most machines but fails on one particular server?

Answers


Looks like I've fixed it. For some reason I was seeing a double postback. This was calling my code to reset the session variables in Page_Load at the wrong time. The work around is to reset the session variables in the page that links to the upload page so they are reset before the page is loaded. I've no idea why I'm seeing the double postback.


Need Your Help

PHP script that generates an optimal schedule for employees - please point me to the right direction

php scheduling

I have to create a PHP script that would generate an optimal schedule for several student assistants. User input is the student assistant's class schedule, and from this information his free time w...

need to modify this Regex to not remove a character

javascript regex

I have the following regexp (/\?(.*?)\&amp;/) which when I use it in the following javascript code it removes the "?" from the replacement result.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.