Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Array data binding


Message #1 by "Jacques Leclerc" <jleclerc2@h...> on Thu, 23 Nov 2000 20:14:30 -0500
I'veable to do databinding to a single dimension array. Is it possible to

bind to a 2 dimensional array? Does anyone have an example?



Thanks



Jacques

jacques_leclerc@h...





Message #2 by Scott Guthrie <scottgu@m...> on Sat, 25 Nov 2000 20:21:14 -0800
Here is an example of binding to a two-dimensional array.



Thanks,



Scott



----------------------------------------



<html>



   <script language="C#" runat=server>



       void Page_Load(Object sender, EventArgs e) {



          int [][] MyArray = new int[5][];



          for (int i=0; i<5; i++) {



             MyArray[i] = new int[6];



             for (int x=0; x<6; x++) {

                MyArray[i][x] = x+(6*i);

             }

          }



          Outer.DataSource = MyArray;

          Outer.DataBind();

       }



   </script>



   <body>



      <asp:datalist id="Outer" runat=server>



         <template name="ItemTemplate">



            Here is an array's values:



            <asp:repeater datasource="<%#Container.DataItem%>" runat=server>



               <template name="ItemTemplate">



                  <%# Container.DataItem %>



               </template>



            </asp:repeater>



         </template>



      </asp:datalist>



   </body>



</html>



-----Original Message-----

From: Jacques Leclerc [mailto:jleclerc2@h...]

Sent: Thursday, November 23, 2000 5:15 PM

To: ASP+

Subject: [aspx] Array data binding





I'veable to do databinding to a single dimension array. Is it possible to

bind to a 2 dimensional array? Does anyone have an example?



Thanks



Jacques

jacques_leclerc@h...







Message #3 by "Jacques Leclerc" <jleclerc2@h...> on Mon, 27 Nov 2000 09:15:24 -0500
Scott,

    Thanks for the sample. In reviewing the code and output, I noticed that

each row is returned as a single entity. In the output all the values are

within a single <TD></TD> pair. Is there any way, using an array, of having

each value in a row appear in it's own column?



For my immediate project, I swithched from an array to a programmically

created DataSet. This solved the problem, but I was wondering if using an

array instead of a dataset would be faster. Need to gain as much speed as

possible since the calculations to populate the array can be rather

extensive.



Sample of the page can be found at:

http://aspx1.brinkster.com/jleclerc/allele.aspx



Thanks for your input.



Jacques



"Scott Guthrie" <scottgu@m...> wrote in message news:21311@a...

>

> Here is an example of binding to a two-dimensional array.

>

> Thanks,

>

> Scott

>

> ----------------------------------------

>

> <html>

>

>    <script language="C#" runat=server>

>

>        void Page_Load(Object sender, EventArgs e) {

>

>           int [][] MyArray = new int[5][];

>

>           for (int i=0; i<5; i++) {

>

>              MyArray[i] = new int[6];

>

>              for (int x=0; x<6; x++) {

>                 MyArray[i][x] = x+(6*i);

>              }

>           }

>

>           Outer.DataSource = MyArray;

>           Outer.DataBind();

>        }

>

>    </script>

>

>    <body>

>

>       <asp:datalist id="Outer" runat=server>

>

>          <template name="ItemTemplate">

>

>             Here is an array's values:

>

>             <asp:repeater datasource="<%#Container.DataItem%>"

runat=server>

>

>                <template name="ItemTemplate">

>

>                   <%# Container.DataItem %>

>

>                </template>

>

>             </asp:repeater>

>

>          </template>

>

>       </asp:datalist>

>

>    </body>

>

> </html>

>

> -----Original Message-----

> From: Jacques Leclerc [mailto:jleclerc2@h...]

> Sent: Thursday, November 23, 2000 5:15 PM

> To: ASP+

> Subject: [aspx] Array data binding

>

>

> I'veable to do databinding to a single dimension array. Is it possible to

> bind to a 2 dimensional array? Does anyone have an example?

>

> Thanks

>

> Jacques

> jacques_leclerc@h...

>

>

>

>

>






  Return to Index