|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Gridview - Accessing a field value in current rowHi all,
I can currently access a row value using the following: GridViewRow g = g.Rows[1]; string s = g.Cells[1].Text; However, I need this particular field to be invisible. I only put it in the grid because I need to do stuff with its value, but, the user doesn't need to see it. However, when a field is invisible the Cells collection doesn't see it. Anyone have any suggestions? TIA, Joe Hi,
invisible fields are not kept in ViewState. Therefore you need to add the field to DataKeyNames of the GridView so that it is kept over postbacks while the field is invisible. Show quoteHide quote "Joe Reiss" <joere***@bellsouth.net> wrote in message news:0Sjuf.100425$aS5.96213@bignews4.bellsouth.net... > Hi all, > > I can currently access a row value using the following: > > GridViewRow g = g.Rows[1]; > string s = g.Cells[1].Text; > > However, I need this particular field to be invisible. I only put it in > the grid because I need to do stuff with its value, but, the user doesn't > need to see it. However, when a field is invisible the Cells collection > doesn't see it. Anyone have any suggestions? > > TIA, > Joe > This particular field is not a key for this grid. There is already another
field that is the key. Any other suggestions? Thanx, Joe Show quoteHide quote "Teemu Keiski" <jot***@aspalliance.com> wrote in message news:eVo9M2IEGHA.3064@TK2MSFTNGP14.phx.gbl... > Hi, > > invisible fields are not kept in ViewState. Therefore you need to add the > field to DataKeyNames of the GridView so that it is kept over postbacks > while the field is invisible. > > -- > Teemu Keiski > ASP.NET MVP, AspInsider > Finland, EU > http://blogs.aspadvice.com/joteke > > "Joe Reiss" <joere***@bellsouth.net> wrote in message > news:0Sjuf.100425$aS5.96213@bignews4.bellsouth.net... >> Hi all, >> >> I can currently access a row value using the following: >> >> GridViewRow g = g.Rows[1]; >> string s = g.Cells[1].Text; >> >> However, I need this particular field to be invisible. I only put it in >> the grid because I need to do stuff with its value, but, the user doesn't >> need to see it. However, when a field is invisible the Cells collection >> doesn't see it. Anyone have any suggestions? >> >> TIA, >> Joe >> > > That doesn't actually mind, GridView does not check for uniqueness, I dare
to doubt and you can have multiple key columns with GridView. It's just the simplest solution :-) Check following ASP.NEt Forum post for reference: http://forums.asp.net/937935/ShowPost.aspx If you want to, you can try having a TemplateField, a Label in it and bind the field as Text to that Label. Then you could access the value from that field. Show quoteHide quote "Joe Reiss" <joere***@bellsouth.net> wrote in message news:_ZCuf.10806$vL4.5887@bignews1.bellsouth.net... > This particular field is not a key for this grid. There is already > another field that is the key. > > Any other suggestions? > > Thanx, > Joe > > "Teemu Keiski" <jot***@aspalliance.com> wrote in message > news:eVo9M2IEGHA.3064@TK2MSFTNGP14.phx.gbl... >> Hi, >> >> invisible fields are not kept in ViewState. Therefore you need to add the >> field to DataKeyNames of the GridView so that it is kept over postbacks >> while the field is invisible. >> >> -- >> Teemu Keiski >> ASP.NET MVP, AspInsider >> Finland, EU >> http://blogs.aspadvice.com/joteke >> >> "Joe Reiss" <joere***@bellsouth.net> wrote in message >> news:0Sjuf.100425$aS5.96213@bignews4.bellsouth.net... >>> Hi all, >>> >>> I can currently access a row value using the following: >>> >>> GridViewRow g = g.Rows[1]; >>> string s = g.Cells[1].Text; >>> >>> However, I need this particular field to be invisible. I only put it in >>> the grid because I need to do stuff with its value, but, the user >>> doesn't need to see it. However, when a field is invisible the Cells >>> collection doesn't see it. Anyone have any suggestions? >>> >>> TIA, >>> Joe >>> >> >> > >
Any hints on how to do frames in ASP.Net 2.0?
Code to select item in dropdown populated using TableAdapter Referencing controls inside Wizard control Custom Treenodes in Treeview Would like to get two items from a dropdownlist Problem in Setting SelectedValue for DropdownList in Form DropDownList VS TextBox CheckBoxList - When does it actually databind? TreeView controlToValidate property of compareValidator |
|||||||||||||||||||||||