Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Textbox Value

Posted on 2012-04-01
13
325 Views
Last Modified: 2012-08-14
Hello:

I am trying to show a value in a textbox that I got from a database table. I know the data is pulling the values correctly. Here is my textbox:

<asp:TextBox ID="NameText" Text="<%# adjName %>" runat="server" Width="200px" />

Dan
0
Comment
Question by:RecipeDan
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37794353
Unfortunately, that is not enough markup to go on. We would need to see what container you are using (e.g. Repeater, GridView, etc.) in order to give you proper syntax to databind with. Can you elaborate?
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 37794362
If adjName is a server side variable with the value you want to assign, then it must be declared public in your server code in order to acces it with <%# adjName %> in aspx page.

        public string adjName;
0
 
LVL 1

Author Comment

by:RecipeDan
ID: 37794505
OK hereis my whole aspx:

 <ajaxToolkit:TabContainer ID="ProfileContainer" TabStripPlacement="Top" runat="server" Width="650" BorderColor="Black" ActiveTabIndex="0">
<ajaxToolkit:TabPanel runat="server" HeaderText="Header1" ID="Tab1">
        <ContentTemplate>
            <table cellpadding="3" style="width: 558px">
            <tr>
            <td><asp:Label runat="server" CssClass="RequiredLabelClass" Text="Name:" ID="NameLabel" /></td>
            <td><<asp:TextBox ID="NameText" Text="<%# adjName %>" runat="server" Width="200px" /></td>
            </tr>

            </table>
        </ContentTemplate>

        </ajaxToolkit:TabPanel>
       
        <ajaxToolkit:TabPanel runat="server" HeaderText="Header2" ID="Tab2">
           
        </ajaxToolkit:TabPanel>
   
    </ajaxToolkit:TabContainer>
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 21

Expert Comment

by:masterpass
ID: 37794518
so adjName is a varibale in the server side ? If yes, like tommyboy said .. make it public and then try accessing it like this

Text="<%= adjName %>"
0
 
LVL 5

Expert Comment

by:Rainverse
ID: 37796166
What he said ^^.  Replace the # with an =.  <%= adjName %>

-MJC
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 150 total points
ID: 37796190
Respone.Write sytnax ( <%= ... %> ) does not work within properties of server controls (AFAIK). Data-binding syntax ( <%# ... %> ) would be the proper way of making a property bound to some backing data store.

Please let us know where the data is coming from. I don't see where you have connected your ajaxToolkit:TabContainer to a data source.
0
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 200 total points
ID: 37796319
Assuming it's a publicly declared server variable, it would have to be done using javascript.

<body>
    <form runat="server" id="form1">
         <asp:TextBox ID="NameText" runat="server" Width="200px" />
    </form>
    <script type="text/javascript">        
         document.getElementById("NameText").value = "<%= adjName %>";
    </script>
</body>
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37796359
Assuming it's a publicly declared server variable, it would have to be done using javascript.
What about code-behind?  ; )
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 37796372
You're right, it would be kind of pointless.
0
 
LVL 1

Author Comment

by:RecipeDan
ID: 37796896
Hello:

The tab container itself is not connected to a datasource. I have a form in the tab container that I want to get values from a database. The values are pulling from he database because I tested it with asp:label and the values show. I can't get the values to show in the textbox.
0
 
LVL 21

Assisted Solution

by:masterpass
masterpass earned 150 total points
ID: 37798417
Try like this
TextBox nameTxt = (TextBox) ProfileContainer.FindControl("Tab1").FindControl("NameText");
nameTxt.text = "value from database";

Open in new window

Hope this helps!
0
 
LVL 1

Accepted Solution

by:
RecipeDan earned 0 total points
ID: 37804545
I figured it out. This works:

<asp:TextBox ID="NameText" runat="server" Width="200px" />

NameText.Text = Convert.ToString(reader["UserName"]);
0
 
LVL 1

Author Closing Comment

by:RecipeDan
ID: 37820946
See Comment. I figured it out on my own.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question