C# Request.From Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karenRoss
    New Member
    • Jun 2007
    • 27

    #1

    C# Request.From Array

    ArrayList temp = new ArrayList();
    foreach (string var in Request.Form)
    {
    temp.Add(var);
    }

    This is the code I'm using to pull out the items in my form. However, I cannot seem to get the values of the data entered into the form. I'm just getting the names of all the objects in the form, but I really want the data as well. Am I missing something?
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by karenRoss
    ArrayList temp = new ArrayList();
    foreach (string var in Request.Form)
    {
    temp.Add(var);
    }

    This is the code I'm using to pull out the items in my form. However, I cannot seem to get the values of the data entered into the form. I'm just getting the names of all the objects in the form, but I really want the data as well. Am I missing something?
    You are close but you will need to find the name of each object on the form so that you can retrieve the values of those objects. Use a loop similar to the one below to retrieve the value for each object on your form.

    Code:
    string[] strKeys;
    string[] strValues;
      
    strKeys = Request.Form.AllKeys;
    for (int i = 0; i < Request.Form.Count; i++) 
    {
                strValues = Request.Form.GetValues(i);
    }
    Nathan

    Comment

    • karenRoss
      New Member
      • Jun 2007
      • 27

      #3
      Thanks for the reply :)\

      I ended up taking the name and value at the same time in the same array.

      Comment

      Working...