Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Textbox Value

Posted on 2012-04-01
13
Medium Priority
?
333 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
Independent Software Vendors: 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!

 
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 600 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 800 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 600 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 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