Solved

Textbox Value

Posted on 2012-04-01
13
323 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now