Solved

showing array results in a web form

Posted on 2007-03-24
9
224 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
  • 5
  • 4
9 Comments
 
LVL 13

Accepted Solution

by:
KarinLoos earned 500 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
 

Author Comment

by:mrperfect75000
ID: 18788716
This is my html

 <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="348px">
                </asp:GridView>
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now