displaying Accessdatasource field in textbox using ASP.Net and VS.Net 2005 ?

L

Luqman

How can I display any field value in textbox of sqldatasource using VS.Net
2005 ?

Say : Dim x as new AccessDataSource
X.connectionstring="Data source="D:\mydb.mdb"
X.Selectcommand="Select CompanyName from customers"

Textbox1.text= ??? <-------- I need to display CompanyName Field in this
textbox, how can I ?

Best Regards,

Luqman
 
C

Christopher Reed

How many values do you want to put into your TextBox? Your SQL select
statement will probably return back more than one value.
 
L

Luqman

Hi,

I want to display each field in a separate textbox, so if I have 2 fields,
say, companycode and companyname, I want to display both of them in two
textboxes.

For eg.

Textbox1.text= companycode
Textbox2.text=companyname

But I don't know the syntax, Any idea please ?

Best Regards,

Luqman
 
C

Christopher Reed

You might consider using a FormView which is a template-based data control.
So, within your ASPX page, you could do something like this:

<asp:FormView id="FormView1" runat="server"
DataSourceID="AccessDataSource1">
<ItemTemplate>
<asp:TextBox id="TextBox1" runat="server" Text='<%#
Eval("CompanyCode") %>' />
<asp:TextBox id="TextBox2" runat="server" Text='<%#
Eval("CompanyName") %>' />
</ItemTemplate>
</asp:FormView>
<asp:AccessDataSource id="AccessDataSource" runat="server"
ConnectionString = "Data source=D:\mydb.mdb"
SelectCommand = "Select CompanyCode, CompanyName from customers" />

Depending your actual set up, you may have to tweak the above a little.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top