AznCutie Posted March 23, 2003 Posted March 23, 2003 Is it possible to bind data to an HTML table cell? If so, what's the syntax...? For example - I want to show a specific person's record on a page. The source is an mdb file. There's two ways I can think of to do this, and one of them is using a datagrid, however that doesn't produce the desired results... If there's some way of showing a specific item in a cell, then I'd rather do that... Thanks in advance! Quote
Moderators Robby Posted March 23, 2003 Moderators Posted March 23, 2003 I don't think you can bind to an HTML table. SOrry I didn't get it, what do you want to do? Quote Visit...Bassic Software
AznCutie Posted March 23, 2003 Author Posted March 23, 2003 I don't think you can bind to an HTML table. SOrry I didn't get it, what do you want to do? Basically pull up a user or employee's record, showing their email address, mailing address, etc... Information that's stored in a database, and shown in a table. Basically, like this. Quote
wyrd Posted March 23, 2003 Posted March 23, 2003 The way they do this is using templates with the DataGrid or DataList web control. Quote Gamer extraordinaire. Programmer wannabe.
Moderators Robby Posted March 23, 2003 Moderators Posted March 23, 2003 The link errors out, the msg is... Line 39: objCN.Close() Line 40: lblEmployeeID.Text = _ Line 41: objDS.Tables("EmployeeData").Rows(0)!EmployeeID It looks like a Dataset is feeding a Label, the rest of it may be a DataGrid or DataList (as wyrd said). Quote Visit...Bassic Software
AznCutie Posted March 23, 2003 Author Posted March 23, 2003 Okay... I got that... For some reason, it's still bugging out though. Can anyone help me out? Sub Page_Load(Sender As Object, E As EventArgs) Dim objCN as OleDbConnection 'Database Connection object Dim objDA as OleDbDataAdapter 'Database Adaptor object Dim objDS as DataSet 'Dataset object Dim objCM as OleDbCommand Dim strSQL as String Dim strCN as String If Not IsPostBack Then strCN = "PROVIDER = Microsoft.Jet.OLEDB.4.0;" & "DATA SOURCE=" & Server.MapPath("emps.mdb;" ) objCN = New OleDbConnection( strCN ) objCN.Open() strSQL = " SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = @EmployeeID" objDA = New OleDBDataAdapter( strSQL, objCN ) objDA.SelectCommand.Parameters.Add("@EmployeeID") objDS = New DataSet objDA.Fill(objDS, "Employees") objCN.Close() lblEmployeeID.text = objDS.Tables("EmployeeData").Rows(0)!EmployeeID lblName.text = objDS.Tables("EmployeeData").Rows(0)!LastName lblDepartment.text = objDS.Tables("EmployeeData").Rows(0)!DepartmentID lblEmail.text = objDS.Tables("EmployeeData").Rows(0)!EmailAddress lblNumber.text = objDS.Tables("EmployeeData").Rows(0)!PhoneNumber lblNotes.text = objDS.Tables("EmployeeData").Rows(0)!Notes end if end sub Quote
wyrd Posted March 23, 2003 Posted March 23, 2003 It's hard to tell without you posting the error messages, but a few things.. Change your page load to.. Sub Page_Load() And also your connection string seems a little funky, perhaps change it to.. strCN = "PROVIDER = Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & Server.MapPath("emps.mdb") And your parameter is wrong I believe. You're using the set up for SQL Server classes, but you're using OleDB. Change your sql select to; strSQL = " SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = ?" And also your parameter itself seems wrong. It should be ("@paramter", source) and all you have is parameter. Perhaps change it to something like; objDA.SelectCommand.Parameters.Add("@EmployeeID", txtEmployeeID.Text) As a last thing, you can bind data to ANY web control (as far as I know). I noticed that you're using labels, and you can bind data to your labels. I'd suggest searching for info in the MSDN library. Anyway, hope that helps.. I have a limited knowledge of ASP.NET stuff, but hopefully I at least set you in the right direction. If you need more help post the code, the error message, and what line the error(s) are on. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.