DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 8 Aug 2007 07:37:12 +0100,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Rob Meade
          2    Ross Culver
          3    Joey
          4    Ross Culver


GridView Question   
Hi all,

In the past I've typically steered away from DataGrids and have just created 
my own tables by programmatically adding rows/cells however yesterday I used 
a DataView for the first time.  Initially I was quite pleased with the 
quickness in getting it to populate with my own collection class and display 
results to the page.

There were some oddities...

1. If I get 5 columns and set one of them to have Visible=False (as I want 
the value from the data but dont want it displayed) the value comes through 
as "", the only way I could get around this was to set Visible = False in my 
code after I'd got the value (e.Row.Cells(4) etc etc) as opposed to setting 
the same attribute in the source view on the page.  A colleague mentions you 
used to be able to do this with a DataGrid in .Net 1.1 and you could still 
access the value?

2. I was hoping that for each row of data that I had I would be able to 
"display" two rows, the first would have a couple of data items, and then 
the second row would display one data item which is a "summary" and thus 
contains quite a lot of text.  I've tried several things but haven't yet 
found a way to do this.  Only ideas really seem to be to have only ONE cell 
displayed and then create my own table inside it, that seems a bit daft as I 
might as well just create my own table and save on the code written to the 
page.  Is there anyway to use some form of template like you can with a 
repeater control?  The only reason I'm still investigating this is primarily 
because I would appreciate the "free" functionality of paging on the 
DataView as opposed to having to write my own for my own table code.

Any help/advise would be really appreciated.

Regards

Rob
Date:Wed, 8 Aug 2007 07:37:12 +0100   Author:  

Re: GridView Question   
Rob,

Make your key value invisible.  Then add it to your DataKeyNames list with 
your DataMember = DefaultView.  The in your code you can access that key 
value using the selecteddatakey.value of the gridview or 
gridview.Datakeys.item(index).value property.
Ross


"Rob Meade"  wrote in message 
news:O0b$OaY2HHA.1124@TK2MSFTNGP06.phx.gbl...

> Hi all,
>
> In the past I've typically steered away from DataGrids and have just 
> created my own tables by programmatically adding rows/cells however 
> yesterday I used a DataView for the first time.  Initially I was quite 
> pleased with the quickness in getting it to populate with my own 
> collection class and display results to the page.
>
> There were some oddities...
>
> 1. If I get 5 columns and set one of them to have Visible=False (as I want 
> the value from the data but dont want it displayed) the value comes 
> through as "", the only way I could get around this was to set Visible = 
> False in my code after I'd got the value (e.Row.Cells(4) etc etc) as 
> opposed to setting the same attribute in the source view on the page.  A 
> colleague mentions you used to be able to do this with a DataGrid in .Net 
> 1.1 and you could still access the value?
>
> 2. I was hoping that for each row of data that I had I would be able to 
> "display" two rows, the first would have a couple of data items, and then 
> the second row would display one data item which is a "summary" and thus 
> contains quite a lot of text.  I've tried several things but haven't yet 
> found a way to do this.  Only ideas really seem to be to have only ONE 
> cell displayed and then create my own table inside it, that seems a bit 
> daft as I might as well just create my own table and save on the code 
> written to the page.  Is there anyway to use some form of template like 
> you can with a repeater control?  The only reason I'm still investigating 
> this is primarily because I would appreciate the "free" functionality of 
> paging on the DataView as opposed to having to write my own for my own 
> table code.
>
> Any help/advise would be really appreciated.
>
> Regards
>
> Rob
> 
Date:Wed, 8 Aug 2007 08:59:03 -0500   Author:  

Re: GridView Question   
On Aug 8, 1:37 am, "Rob Meade"  wrote:

> Hi all,
>
> In the past I've typically steered away from DataGrids and have just created
> my own tables by programmatically adding rows/cells however yesterday I used
> a DataView for the first time.  Initially I was quite pleased with the
> quickness in getting it to populate with my own collection class and display
> results to the page.
>
> There were some oddities...
>
> 1. If I get 5 columns and set one of them to have Visible=False (as I want
> the value from the data but dont want it displayed) the value comes through
> as "", the only way I could get around this was to set Visible = False in my
> code after I'd got the value (e.Row.Cells(4) etc etc) as opposed to setting
> the same attribute in the source view on the page.  A colleague mentions you
> used to be able to do this with a DataGrid in .Net 1.1 and you could still
> access the value?
>
> 2. I was hoping that for each row of data that I had I would be able to
> "display" two rows, the first would have a couple of data items, and then
> the second row would display one data item which is a "summary" and thus
> contains quite a lot of text.  I've tried several things but haven't yet
> found a way to do this.  Only ideas really seem to be to have only ONE cell
> displayed and then create my own table inside it, that seems a bit daft as I
> might as well just create my own table and save on the code written to the
> page.  Is there anyway to use some form of template like you can with a
> repeater control?  The only reason I'm still investigating this is primarily
> because I would appreciate the "free" functionality of paging on the
> DataView as opposed to having to write my own for my own table code.
>
> Any help/advise would be really appreciated.
>
> Regards
>
> Rob


I just finished upgrading an asp.net 1.1 application to asp.net 2.0.
The app had lots of datagrids, and I had been using visible=false on
many of the columns. I would have to say that I agree with Ross about
DataKeyNames. When you use them, for each row in the data source the
specified value (i.e. RoleId, etc...) is added into the grid. Just add
your attribute name (or names separated by commas) to the
DataGridView's DataKeyNames property. You can then access it in code
like this...

protected void grdMyGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
   if(this.grdMyGridView.DataKeys[e.Row.RowIndex].Values[0].ToString()
== "SomeValue")
   {
      //execute some code
   }
}

In the above example if you have used more than one datakey, you could
access the second with .Values[1].ToString() instead
of .Values[0].ToString() etc...

Also, I too used to manually construct grids with code by using table,
tr, td and other tags. Once I realized how to tap into the various
available events for grids (i.e. RowDataBound, RowDeleting, etc...), I
quickly began to see the err of my ways!

Finally, to get your two rows you may choose to access the cell within
a RowDataBound or other event handler and then embed text for a table
(with two rows) as the cell data. You can tell the gridview to allow
your HTML text by setting the column's HTMLEncode property to False.

HTH,
JP
}
Date:Wed, 08 Aug 2007 07:39:01 -0700   Author:  

Re: GridView Question   
Have you tried converting the column field to a template field?  Once you've 
done that, you can do all kinds of cool things.

Ross

"Rob Meade"  wrote in message 
news:O0b$OaY2HHA.1124@TK2MSFTNGP06.phx.gbl...

> Hi all,
>
> In the past I've typically steered away from DataGrids and have just 
> created my own tables by programmatically adding rows/cells however 
> yesterday I used a DataView for the first time.  Initially I was quite 
> pleased with the quickness in getting it to populate with my own 
> collection class and display results to the page.
>
> There were some oddities...
>
> 1. If I get 5 columns and set one of them to have Visible=False (as I want 
> the value from the data but dont want it displayed) the value comes 
> through as "", the only way I could get around this was to set Visible = 
> False in my code after I'd got the value (e.Row.Cells(4) etc etc) as 
> opposed to setting the same attribute in the source view on the page.  A 
> colleague mentions you used to be able to do this with a DataGrid in .Net 
> 1.1 and you could still access the value?
>
> 2. I was hoping that for each row of data that I had I would be able to 
> "display" two rows, the first would have a couple of data items, and then 
> the second row would display one data item which is a "summary" and thus 
> contains quite a lot of text.  I've tried several things but haven't yet 
> found a way to do this.  Only ideas really seem to be to have only ONE 
> cell displayed and then create my own table inside it, that seems a bit 
> daft as I might as well just create my own table and save on the code 
> written to the page.  Is there anyway to use some form of template like 
> you can with a repeater control?  The only reason I'm still investigating 
> this is primarily because I would appreciate the "free" functionality of 
> paging on the DataView as opposed to having to write my own for my own 
> table code.
>
> Any help/advise would be really appreciated.
>
> Regards
>
> Rob
> 
Date:Wed, 8 Aug 2007 14:32:18 -0500   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us