eramgarden Posted June 25, 2004 Posted June 25, 2004 I have a datagrid with ONE cell. In that ONE cell, I have a table with rows and columns... I want, Depending on "MODE", hide the value bound to txtAdd18 ... I tried: e.Item.Cells(0).Visible = False But this hides the WHOLE cell since i ONLY HAVE ONE CELL... I also tried: e.Item.Cells(0).FindControl("txtAdd18").Visible = False But got an error that object is not set... Anyway to do this without creating a new DataGrid for different Modes?? Code looks something like this: <asp:datagrid id=... [b]OnItemDataBound="dg_hide"[/b]> <Columns> <asp:TemplateColumn> <ItemTemplate> <table> <tr> <td> <%# Container.DataItem("Other9") %> </td> </tr> <tr> <td> <%# Container.DataItem("Other10") %> </td> </tr> </table> </ItemTemplate> <EditItemTemplate> <tr><td>[b]<asp:Textbox id="txtAdd18"... />[/b]</td></tr> <tr><td>...</td></tr> Quote
Arch4ngel Posted June 25, 2004 Posted June 25, 2004 txtAdd18.Visible = false won't work ? being invisible won't render it by the way... (server-side) so no events will occur. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
eramgarden Posted June 25, 2004 Author Posted June 25, 2004 NO, that wont work. This is inside a DATAGRID... There has to be a way to do this: when you only have ONE CELL, with rows/columns of data in it...how do you access the values in that ONE cell?? Quote
Arch4ngel Posted June 25, 2004 Posted June 25, 2004 Quick solution TextBox txt = (TextBox)dgPosts.Items[0].Cells[0].FindControl("txtAdd18"); txt.Visible = false; Dim txt as TextBox = CType(dgPosts.Items[0].Cells[0].FindControl("txtAdd18"), TextBox) txt.Visible = False I didn't know in which language you were programming. But try this. it's worth a try. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
eramgarden Posted June 25, 2004 Author Posted June 25, 2004 I tried your code and this: Dim txtP As TextBox = CType(dgContactAddInfoBottom.Items(0).FindControl("txtPhone"), TextBox) Dim txtH As TextBox = CType(dgContactAddInfoBottom.Items(0).FindControl("txtHours"), TextBox) txtP.Visible = False txtH.Visible = False But when it gets to txtP, i get error msg that object is not set. Any ideas? Quote
Arch4ngel Posted June 25, 2004 Posted June 25, 2004 Maybe your control didn't exists. My recommendation... look into Controls property the verify that it's in this line. take a look at other lines too (maybe have more than one even If only one is showed). But really look into Controls collection in debug mode. Maybe your control isn't created yet. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
eramgarden Posted June 25, 2004 Author Posted June 25, 2004 I have that code right after databinding to the datagrid.. but let me play around with it more. Will post again. Thanks for all your help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.