Solved

Textbox Value

Posted on 2012-04-01
13
327 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
[X]
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
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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