Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

showing array results in a web form

Posted on 2007-03-24
9
Medium Priority
?
239 Views
Last Modified: 2013-11-07
Hi guys,

I need some help with showing an array in a aspx web page...

I want to post the results on to a web page. ....Could you please show me how to do these with a sample or resources....

 May be by writing strings of html with Response.Write

or

or using ASP.NET's Table and TableRow control

I dont know which one is better...or how to go about it..

i have this iteration in my code behind....

 wservices.NServices service = new wservices.NServices();

        Event[] eventArray = service.Get(222, null, null, null, null, new DateTime(2007, 4, 1), null,         33, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,         null, null);

int i;
        for (i = 0; i < eventArray.Length; i++)
        {

            Object obj = eventArray[i];
         
        }
0
Comment
Question by:mrperfect75000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 13

Accepted Solution

by:
KarinLoos earned 2000 total points
ID: 18786068
You might try converting the array to an arraylist .. Then simply bindng the arraylist to a gridview.
In your HTML put  Gridview control and then in code behind.
ArrayList eventArrayList= ArrayList.Adapter(eventArray);
Gridview1.Datasource = eventArrayList;
Gridview1.Databind().



0
 

Author Comment

by:mrperfect75000
ID: 18787408
Thanks! That seems to work after i added using System.Collections;  but i still get an error..

The name 'Gridview1' does not exist in the current context      

any idea why? I added the gridview to the aspx page...
0
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18788695
1. doublecheck name  Gridview1 (c# is case sensitive).
2. check you have the runat=server in the html (ie <asp:Gridview id="grid" runat="server"..
If none of the above work. please post your html .
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:mrperfect75000
ID: 18788716
This is my html

 <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="348px">
                </asp:GridView>
0
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18788760
When are you getting the error regarding context, when trying to bind to the grid?
0
 

Author Comment

by:mrperfect75000
ID: 18788766
No, when assing the datasource

Gridview1.Datasource = eventArrayList;
0
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18791532
Sorry to be a pain, however c# is case sensitive
in your above post :   Gridview1.Datasource = eventArrayList;  the v in Gridview is not with a capital v
and in your html example  <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged ..
it is.

Try    GridView1.Datasource   .
0
 

Author Comment

by:mrperfect75000
ID: 18793302
Thanks!! That seems to have worked - thats so weird i spent almost 3 days trying to fix that!!  -

However i got another error - if you dont mind checking this one out please

Error      2      'System.Web.UI.WebControls.GridView' does not contain a definition for 'Datasource'      

any idea why i'm getting this one?
0
 

Author Comment

by:mrperfect75000
ID: 18793510
Ok - same problem - its working now ! thanks
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question