Author |
Topic |
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-07 : 11:30:20
|
I need some help with a table and database. I have a table that I want to use as a include file. The thing is that I want that table to change label depending on which database it is accessing.Example:Database: SaleNameDatePurchaseDatabase: ReOrderNameDateVendorEtc..I tried doing the following: <% If Session("Database") = "Sale" %><asp:TableCell>Name</asp:TableCell> <asp:TableCell> <asp:textbox id="txtName" runat="server"></asp:textbox> <asp:TableCell><asp:TableCell>Date</asp:TableCell> <asp:TableCell> <asp:textbox id="txtDate" runat="server"></asp:textbox> <asp:TableCell><asp:TableCell>Purchase</asp:TableCell> <asp:TableCell> <asp:textbox id="txtPurchase" runat="server"></asp:textbox> <asp:TableCell><% Else %><asp:TableCell>Name</asp:TableCell> <asp:TableCell> <asp:textbox id="txtName" runat="server"></asp:textbox> <asp:TableCell><asp:TableCell>Date</asp:TableCell> <asp:TableCell> <asp:textbox id="txtDate" runat="server"></asp:textbox> <asp:TableCell><asp:TableCell>Vendor</asp:TableCell> <asp:TableCell> <asp:textbox id="txtVendor" runat="server"></asp:textbox> <asp:TableCell>The problem is that it gives me an error when I try to run this. Says "Code blocks are not supported in this context". Any ideas? |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2005-03-07 : 13:05:54
|
Why don't you just do it all in code behind? Also, just use 1 set of controls, and change the text based on the conditions.-Chadhttp://www.phxpoker.comPhoenix's largest online poker community |
 |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-07 : 14:06:21
|
Yes that would be the logical thing to do. I'm using an conditional statement, but having minor problem.Dim strName As StringDim strDate As DateDim strPurchase As StringDim strReOrder As StringIf Session("Database") = "ACCT" Then strName = "Name" strDate = "Date" strPurchase = "Purchase"Else strName = "Name" strDate = "Date" strReOrder = "ReOrder"End If<asp:TableCell CssClass="Normal"><%# strName %></asp:TableCell><asp:TableCell CssClass="Normal"><%# strDate %></asp:TableCell><asp:TableCell CssClass="Normal"><%# strPurchase %></asp:TableCell>I want to put the string there, but it's not displaying it there. What do I need to do so that it will change the label to that certain name? |
 |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2005-03-07 : 14:46:39
|
You need to call Page.DataBind() after this this code for it to work.-Chadhttp://www.phxpoker.comPhoenix's largest online poker community |
 |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-07 : 15:19:44
|
Thanks. I got it all working now. |
 |
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2005-03-07 : 15:42:46
|
You should probably look into a Repeater or Datagrid for this type of thing. I think they are much easier to work with instead of building all of these server-side tables.Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-08 : 09:53:00
|
Yeah it would be easier to work with, but I'm migrating this from .ascx to .aspx and I don't want to start all over. Just modify some codes to get it working in .aspx. |
 |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2005-03-08 : 11:45:59
|
That shouldn't require code changes. Just change the extension, change what it inherits from, and change the control directive to a page directive.Why do you need to do that though? Why not just put the control on a page?-Chadhttp://www.phxpoker.comPhoenix's largest online poker community |
 |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-08 : 13:34:32
|
Yeah that's what I pretty much did. Change the extension, add some reference, etc.The .ascx was use with DotNetNuke portal and we want to make it a standalone app. So some of the modification was to get it to work without relying on inheritance. |
 |
|
|