Solved

showing array results in a web form

Posted on 2007-03-24
9
228 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 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

732 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