Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid trouble please help

Reply
Thread Tools

DataGrid trouble please help

 
 
Priya via .NET 247
Guest
Posts: n/a
 
      08-09-2004
I am creating an small application to display data from a SQL back end using a stored procedure.

DataGrid1.DataSource = MyService.viewTable();
DataGrid1.DataBind();

I set the property so as not to display a particular Column

DataGrid1.Columns[1].Visible = !DataGrid1.Columns[1].Visible;

It gave me an array out of bound exception. So I displayed the value of the columns and it shows 0. This statement to display the columns is after DataBind. But if just view the table and not make any changes it displays the table.

Could any one tell me what I am doing wrong.

Thanks,
Priya

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>+wHipw9twEuzDXwd81iPnw==</Id>
 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      08-09-2004
Hi Priya:

If you are using auto-generated columns, I believe the Columns
property does not hold the columns for display. To pull this off
you'll need to set the bound columns for the grid and turn off
autogenerate.

HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 09 Aug 2004 08:38:12 -0700, Priya via .NET 247
<(E-Mail Removed)> wrote:

>I am creating an small application to display data from a SQL back end using a stored procedure.
>
>DataGrid1.DataSource = MyService.viewTable();
>DataGrid1.DataBind();
>
>I set the property so as not to display a particular Column
>
>DataGrid1.Columns[1].Visible = !DataGrid1.Columns[1].Visible;
>
>It gave me an array out of bound exception. So I displayed the value of the columns and it shows 0. This statement to display the columns is after DataBind. But if just view the table and not make any changes it displays the table.
>
>Could any one tell me what I am doing wrong.
>
>Thanks,
>Priya
>
>-----------------------
>Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
><Id>+wHipw9twEuzDXwd81iPnw==</Id>


 
Reply With Quote
 
 
 
 
Rick Spiewak
Guest
Posts: n/a
 
      08-11-2004
I would just do this differently. Use template columns instead of
autogenerating them, and you can define ahead of time which fields you want.
It's much more flexible than counting columns and cells!

"Priya via .NET 247" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am creating an small application to display data from a SQL back end

using a stored procedure.
>
> DataGrid1.DataSource = MyService.viewTable();
> DataGrid1.DataBind();
>
> I set the property so as not to display a particular Column
>
> DataGrid1.Columns[1].Visible = !DataGrid1.Columns[1].Visible;
>
> It gave me an array out of bound exception. So I displayed the value of

the columns and it shows 0. This statement to display the columns is after
DataBind. But if just view the table and not make any changes it displays
the table.
>
> Could any one tell me what I am doing wrong.
>
> Thanks,
> Priya
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>+wHipw9twEuzDXwd81iPnw==</Id>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments