eramgarden Posted March 30, 2004 Posted March 30, 2004 I have a datagrid, have 5 text fields displayed on it. If I'm in ModeA, i want the first Col to have , for example, "Company". If I'm in ModeB, I want the first Col to have, for example, "Contact"... so depending on the mode, I want to change one or 2 text fields ... I can have a panel and just display the right panel for the right mode..but was wondering if there's another way of changing the textfield without using panels... Quote
Moderators Robby Posted March 30, 2004 Moderators Posted March 30, 2004 Do you want for eample "Company" in each row of the first column or as a header for certain rows? Quote Visit...Bassic Software
eramgarden Posted March 30, 2004 Author Posted March 30, 2004 (edited) This is what I want: Mode1: Company Address ... Mode2: Contact Address .... So, display a totally different header in Mode2, update a different field ...Dont want to put this in a panel just because only 2 fields are different from Mode1 and Mode2.. This is what I have: [b]<ItemTemplate>[/b] <table border="0"> <tr> <td align="left"><b>[b]Company:[/b]</b></td> <td> <%# Container.DataItem("cmp_name1") %> </td> </tr> <tr> <td align="left"><b>[b]Address:[/b]</b></td> <td> <%# Container.DataItem("cmp_account") %> </td> </tr> </table> [b]</itemtemplate>[/b] [b]<EditItemTemplate>[/b] <table border="0"> <tr> <td align="left"><b>[b]Company:[/b]</b></td> <td> <%# Container.DataItem("cmm_name1") %> </td> </tr> <tr> <td align="left"><b>[b]Address:[/b]</b></td> <td> <%# Container.DataItem("addr") %> </td> </tr> .... [edit]Removed tabs:Robby[/edit] Edited March 30, 2004 by Robby Quote
MorningZ Posted March 30, 2004 Posted March 30, 2004 Whats driving the switching between Company and Contact? QueryString param? something in the DB ? Quote If you make it idiot proof, they'll build a better idiot :-)
eramgarden Posted March 30, 2004 Author Posted March 30, 2004 Yes, something in the DB. When the user logs in, the choose either Mode1 or Mode2... The "Mode" that I keep in a session variable decides what to display... But not sure how to do it in a datagrid..as I've shown below... Any help to get me going would be great..thanks.. Quote
MorningZ Posted March 30, 2004 Posted March 30, 2004 In the Front: Switch to something like inside the Template: <td align="left"><b><asp:literal id="txtLabel" runat="server"/></b></td> Also add a not-visible BoundColumnwith whatever is the witch <asp:BoundColumn visible="false" DataField="SwitchValue"/> In Code: Use the "OnItemDataBound" event... and you can change the text of the Literal Control based on the value of the BoundColumn Quote If you make it idiot proof, they'll build a better idiot :-)
eramgarden Posted March 31, 2004 Author Posted March 31, 2004 Hmm, couldnt find good examples of what u described..I tried this site: http://aspnet.4guysfromrolla.com/articles/020503-1.aspx I'm using a template.., I think i need to break that template and add a "boundcolumn" ...but then wasnt sure how to do the databinding to the database... so I did this I've seen it in an ASP page...wonder if it's ok to do this in ASP.Net..it does display the info correctly... <tr>[b] <% if session("Mode") = "22" then %>[/b] <td align="left"><b>Company:</b></td> <td> <%# Container.DataItem("cmp") %> </td> [b]<%else%>[/b] <td align="left"><b>Contact:</b></td> <td> <%# Container.DataItem("contact") %> </td> [/b]<%end if %>[/b] </tr> 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.