Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single value binding to Access

Status
Not open for further replies.

AlanJordan

Programmer
Sep 15, 2005
139
0
0
US
I'm new to ASP.Net 2.0. In fact, this is my first ASP.net application.

I've created an Access .mdb file and I've set up a connection. I can use a data reader to write out the data. Thank you CA8MSM.

Now, I'm trying to create a series of text boxes and bind them to the Access database. I tried to use the expression editor that is available through the properties box of a text editor, but the only expression types that I see are AppSettings, connection strings and resources. If I choose Connection strings, the only connection that I see is my Local SQLServer.

I created a Access Data Source, but it does not show up in the connection strings drop down box.

I understand that I should be able to put binding information a property box and then call the page.bind method, but I'm not sure how to do this.

Can anyone point me to an example?

Many thanks.




 
The basic setup is like this:

Code:
<!-- .aspx markup -->
<asp:TextBox ID="txt" Text="<%# MyProperty %>" runat="server"></asp:TextBox>

//in code-beside
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
        Page.DataBind();
}

public string MyProperty
{
    get { return "Value"; }
}

...where the "<%# %>" stuff in the .aspx is the expression you want to bind to (MyProperty in this example) and you call Page.DataBind() to make the page use your value.

You can alternately just do this manually in code, which is just as easy:

Code:
txt.Text = MyProperty;

If you need help getting the data from Excel into the format you'd like for binding, please post further.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top