Solved

showing array results in a web form

Posted on 2007-03-24
9
223 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This is my html

 <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="348px">
                </asp:GridView>
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

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

Author Comment

by:mrperfect75000
Comment Utility
No, when assing the datasource

Gridview1.Datasource = eventArrayList;
0
 
LVL 13

Expert Comment

by:KarinLoos
Comment Utility
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
Comment Utility
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
Comment Utility
Ok - same problem - its working now ! thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

9 Experts available now in Live!

Get 1:1 Help Now