473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Modify ASP Literals with "Code Behind " in .net - General help

36
I have a form which will display general data about a branch. Once you select contacts - then the form will display specific into about that branch. I am trying to add a phone number display to the page, but am having a hard time.

This is the code I am trying to modify. I want to add the phone number after the branch. I would like the data to be displayed similar to: BRANCH NAME: phone number (IOWA: (123) 456-7890)
Expand|Select|Wrap|Line Numbers
  1. <div style="margin-top:15px;margin-bottom:15px;padding:10px;BORDER-TOP: #bfbfa0 1px solid;BORDER-bottom: #bfbfa0 1px solid;">
  2.     <h2>
  3.         <asp:literal id="branch" runat="server"></asp:literal>
  4.     </h2>                
  5. </div>
  6.  
This is the code behind the above code:
Expand|Select|Wrap|Line Numbers
  1. Protected WithEvents contacts As System.Web.UI.WebControls.DataList
  2. Protected WithEvents branchManagers As System.Web.UI.WebControls.DataList
  3. Protected WithEvents showManagers As Panel
  4. Protected WithEvents branch As Literal
  5.  
  6. Private Sub bindData()
  7.         'everything defaults to bettendorf
  8.         Dim branchName As String = "Bettendorf"
  9.         Dim branchNumber As String = Request.QueryString("bid")
  10.         Dim branchLookup As New Hashtable()
  11.         branchLookup.Add("3", "Bettendorf")
  12.         branchLookup.Add("7", "Davenport - Jersey Ridge")
  13.         branchLookup.Add("30", "Davenport - Paul Revere Square")
  14.  
  15.         Dim cn As MySqlConnection
  16.         Dim da As MySqlDataAdapter
  17.         Dim cmd As MySqlCommand
  18.         Dim ds As New DataSet()
  19.  
  20.         'set default branch to bettendorf if its blank
  21.         If (branchNumber = "") Then
  22.             branchNumber = "3"
  23.         End If
  24.  
  25.         'Title Case the branch name for display
  26.         branch.Text = branchLookup.Item(branchNumber)
  27.  
  28.         'select records for the appropriate branch
  29.         Dim query As String = String.Format("SELECT name,title,phone,alias,branch,manager,branch_id FROM Contact WHERE branch_id = '{0}'", branchNumber)
  30.  
  31.         Try
  32.             cn = New MySqlConnection(ConfigurationSettings.AppSettings("cnWWW"))
  33.             cn.Open()
  34.  
  35.             'populate the data
  36.             da = New MySqlDataAdapter(query, cn)
  37.             da.Fill(ds, "contacts")
  38.  
  39.             If (ds.Tables("contacts").DefaultView.Count = 0) Then
  40.                 cn.Close()
  41.                 da.Dispose()
  42.                 Response.Redirect("?bid=3")
  43.                 Response.End()
  44.             End If
  45.  
  46.             'regular users have the "manager" field set to 0
  47.             ds.Tables("contacts").DefaultView.RowFilter = "manager = '0'"
  48.             contacts.DataSource = ds.Tables("contacts")
  49.             contacts.DataBind()
  50.  
  51.             'branch managers have the "manager" field set to 1
  52.             ds.Tables("contacts").DefaultView.RowFilter = "manager = '1'"
  53.             'display the branch managers if there are any
  54.             If (ds.Tables("contacts").DefaultView.Count > 0) Then
  55.                 branchManagers.DataSource = ds.Tables("contacts")
  56.                 branchManagers.DataBind()
  57.             Else
  58.                 showManagers.Visible = False
  59.             End If
  60.         Catch e As Exception
  61.             Response.Redirect("/locations/")
  62.         Finally
  63.             'clean up
  64.             If (Not IsNothing(cn)) Then
  65.                 cn.Close()
  66.             End If
  67.  
  68.             If (Not IsNothing(da)) Then
  69.                 da.Dispose()
  70.             End If
  71.         End Try
  72.     End Sub
  73.  
I tried to add the phone number in the hastable, but that was not liked, so I assume I did not complete that correctly. I even tried to add a case statement in order to hard code the phone numbers in after the ASP Literal call.

I am still new to the .net programming way of things, but it does not seem like it would be that big of a deal to add a phone number into the code - I have about 40 branches total that would need to be edited.

Does anyone have any suggestions - or can you lead me in a direction on where to look for the answer? This is my first attempt to work with a web page that has "code behinds" so I could be missing some very basic rule.
Thank you in advance for any suggestions you may have for me!
Mar 31 '10 #1
1 2404
Frinavale
9,735 Expert Mod 8TB
Consider using a an ASP.NET Localize control instead of a literal.

:)
Mar 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Askari | last post by:
Hi, How do for do a "select()" on a CheckButton in a menu (make with add_checkbutton(....) )? I can modify title, state, etc but not the "check state". :-( Askari
4
by: J. Campbell | last post by:
From reading this forum, it is my understanding that C++ doesn't require the compiler to keep code that does not manifest itself in any way to the user. For example, in the following: { for(int...
13
by: python | last post by:
hello and thanks for reading this, i have been a dos/windows user using some form of the basic language for 30 years now. i own and run a small programming company and there is one feature that...
2
by: Baldy | last post by:
Hi All is it possible to modify code at run time? I have a set of constants that change at deployment (from development to deployment server and a few other consts) I have a menu item that...
3
by: John Baker | last post by:
Hi: As in the "Wizard of Oz", I want people to "pay no attention to the man behind the curtain", by freezing the screen while a whole lot of things happen. I know about ECHO OFF, but this...
13
by: baumann.Pan | last post by:
when define char *p = " can not modify"; p ='b' ;is not allowed, but if you declare p as char p = "can modify"; p = 'b'; is ok? why?
5
by: Sue & Bill | last post by:
I have: Rectangle rects = new Rectangle; I want to initialize the values of rects as follows: Option A: ======== for (int i=0; i<rects.Length; i++)
1
by: | last post by:
Hi guys! I am a beginner with aspx (i have some background with .asp). And i am trying tu use a 'code-behind' page in order to execute all transactions in that page and leave as clean as possible...
1
by: Girish | last post by:
I understand that the code behind concept is a framework that separates code logic from visulization code. I belive this is true for pages that are mostly static. Ie. Forms elements on a page...
1
by: Krishna | last post by:
In vb2005 I can't modify code in debug mode why? Is it possible to set? Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.