How to pass multiple values in table to another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cubekid
    New Member
    • Nov 2008
    • 6

    How to pass multiple values in table to another form

    Dev't Tool: Visual C# 2003 and Javascript
    System Type: Web Application

    One requirement of the system is to dynamically create a table on client-side (Javascripting using createElement method.) The table has textboxes inside each cell.

    a few sample code:

    Code:
    for (i = 0; i < 4; i ++) // four columns
    {
      textBoxes = document.createElement("INPUT");
      textBoxes.type = "text";
      textBoxes.id = "txt1";
      textBoxes.name = "txtA";
      cell.appendChild(textBoxes);
    }

    These are my options to get the values:
    1. Through querystring -> but not possible because there are many values to be passed.
    (sample: WebForm2.aspx?v alue1=&value2)

    2. Also tried getting it by Request.Form["txtA"]
    I can get the values but it is comma delimited. I cannot get exact data when my input has "," in it.
    (sample: Input1 = "a,b"; Input2= "c"; Request.Form["a,b,c"])
    if to be split, 3 values will be returned instead of 2.

    Maybe there's another option that you can suggest so I can retrieve those multiple data.

    One more thing, I would like those data to be on one-time retrieval because in the INSERT process, I plan to include them on a loop inside a TRANSACTION statement so if one record encountered an error, all will ROLLBACK.
    Last edited by gits; Nov 7 '08, 01:19 PM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Firstly, IDs should be unique, so in the for loop use the index to give the unique ID strings. To avoid the problem of commas, you could rename the text boxes to make them unique.

    Comment

    • cubekid
      New Member
      • Nov 2008
      • 6

      #3
      Re

      Thanks for the reply. I solved the problem by using my 2nd option which I stated before (Request.Form["txtA"]).

      I just created a function that replaces "," with "%2c" so that if a user tends to input a value with ",", the parser will not treat it as a delimiter, thus splitting the returned value accurately.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Thanks for posting back with your solution.

        Comment

        Working...