473,412 Members | 1,944 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,412 software developers and data experts.

binding dt to txt

hey all,
i have an incoming datatable in my web page and i'd like to bind one of the
fields to a textbox. can someone please show me how to do this?

thanks,
rodchar
Mar 29 '07 #1
2 1381

Hi,

When you say binding an incoming datatable to a textbox, do you mean
binding a specific row's column value of the datatable?

Incase you need to bind the textbox to a specific row's cell value, then
probably you could try this option:

<input type="text" id="txtcon" value="<%= dt.Rows[0][0]%>" />

But then, if you need an asp:textbox to be bound through your html code, in
that case, the asp:textbox needs to be supported with another hidden input
textbox, followed by a script.

<input type="text" id="txtcon"
style="DISPLAY:none;"
value="<%= dt.Rows[0][0]%>" />
<asp:TextBox ID="txtContent" runat="Server"></asp:TextBox>

<script type="text/javascript">
document.getElementById("txtContent").value =
document.getElementById("txtcon").value
</script>

This code will be useful if you specifically want to bind in the html source
itself.

But if that is not mandatory, the same can be achived by simply assigning
the text property of the asp:textbox to the particular field value of the
datatable.

Also, the textbox can be bound to only 1 cell value of the entire datatable
at a time.

I hope this helps.
-Parvathy.

Mar 30 '07 #2
thank you very much for the help.
rod.

"Parvathy Padmanabhan" wrote:
>
Hi,

When you say binding an incoming datatable to a textbox, do you mean
binding a specific row's column value of the datatable?

Incase you need to bind the textbox to a specific row's cell value, then
probably you could try this option:

<input type="text" id="txtcon" value="<%= dt.Rows[0][0]%>" />

But then, if you need an asp:textbox to be bound through your html code, in
that case, the asp:textbox needs to be supported with another hidden input
textbox, followed by a script.

<input type="text" id="txtcon"
style="DISPLAY:none;"
value="<%= dt.Rows[0][0]%>" />
<asp:TextBox ID="txtContent" runat="Server"></asp:TextBox>

<script type="text/javascript">
document.getElementById("txtContent").value =
document.getElementById("txtcon").value
</script>

This code will be useful if you specifically want to bind in the html source
itself.

But if that is not mandatory, the same can be achived by simply assigning
the text property of the asp:textbox to the particular field value of the
datatable.

Also, the textbox can be bound to only 1 cell value of the entire datatable
at a time.

I hope this helps.
-Parvathy.
Mar 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
15
by: Tom Gur | last post by:
Hi, What is early/late binding ?
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.