Last post Feb 21, 2010 03:33 PM by hans_v
Feb 21, 2010 02:11 PM|rucci|LINK
Im a newbie and unable to bind an access database to my ASP page. I shall try to provide as much info as possible .
I am using visual web developer 2008 and created a blank webpage - on the webpage i have drag and dropped an accessdatasource control and a text box. I have gone through the wizard and connected the access database to the accessdatasource control.
I dont know what else i need to do to show data from a column in the database. The names of my items are as below.
Name of database : database1
Accessdatasource : accessdatasource1
textbox : textbox1
Can you please advise on how to write the code and if there is anything i need to look out for .
Feb 21, 2010 03:33 PM|hans_v|LINK
You're on the right track. All you need to do now it to drag a FormView control to the page, and bind the datasource control to the formview. Then you need to create a ItemTemplate inside the FormView, and put you TextBox inside this template. Then you can bind
the Text Property of the TextBox to the field of the table:
<asp:FormView ID="FormView1" runat="server" DataSourceID="AccessDatasource1">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("fieldname") %>' />
Some remarks. Instead of an AccessDatasource control, you just as well use an SqlDatasource control. More on this:
More info in using Access can be found in this tutorial (chapter 3 DataSources...)
Also watch this video:
It is not Access, but it will give ou an idea how to use datasources...