There may be something fundamentally wrong with the way I'm thinking.
I have a dataset, with a couple columns, and a few rows. Now, if I wanted to make an editable form for this (one textbox for each column in each row, thus creating a lot of textboxes), how would I go about doing this?
From the current mindset I have, which is very ASP 3.0 based, I'd so something like this:
VB Code:
'Code behind:
Response.Write("<table border=1><tr>")
For intColCount = 0 To ds.Tables(0).Columns.Count - 1
You can see what I'm doing here, and for editable textboxes, I'd just replace the appropriate <td>s, etc, etc, etc.
But a few questions arise:
1) Is this the right way at all?
2) What if I wished to have the output of this above code in the middle of some page where other elements already exist? Would I place this code inline to the ASPX page contents, or is that wrong?
I am just learning ASP.NET and I tend to stay away from having to code HTML. What I did was use the DataList control. Basically, add the controls you want to use for a single dataset row in the DataList's Item Template area and then bind the DataList to the Dataset. The DataList_ItemDataBound event will fire for every row in the Dataset allowing you to populate the controls (there are other methods as well). .NET will handle writing the HTML code to duplicate everything in Item Template area for each row in the dataset.
The concept of DataBinding in .NET seems to be very different than it is in VB. I did use a DataReader and am assuming its the same as using a DataSet. I guess I am also assuming you are using VB.Net for the code behind page....
So much to learn...
If you want a live example of the DataList control in action, checkout the Business Directory at mrpmchamber.ca (browse the directory using the list you will see on the left, which is an Infragistics Treeview control).
BTW, we're making an ASP.NET application that uses the same treeview as you have. And it has the same display problems in FireFox. You might want to look into adding this style there:
FireFox is a Mozilla based browser, i certainly prefer to use it over IE but i have encountered numerous problems getting sites to look the same in both IE and mozilla due to the slightly different ways they obviously interpret html.
Man... i'm glad others are using the code-behind to bind the data, instead of <% container.DataItem %>, and remember you don't have to use FindControl if you know the order of the controls...
Originally posted by brucevde
VB Code:
Private Sub dlstDirectory_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) _
Handles dlstDirectory.ItemDataBound
'check if the ItemDataBound event is firing for the
'Item and/or AlternatingItem rows.
'Ignore the Header and Footer events
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'create a reference to the DataSource of the DataList
Dim oData As System.Data.Common.DbDataRecord = CType(e.Item.DataItem, System.Data.Common.DbDataRecord)
' Retrieve the Label, Image controls in the current DataListItem.
Are you serious? It's a very rapidly rising browser, very popular nowadays. A lot of VBFers use it
Here's the screenshot, attached.
You'll see half the menu items missing, the cursor not becoming a hand, the text on top not highlighted, etc. I know it's probably not a major issue for you, bit I felt should point it out, since you're from/near Vancouver too
Ignore the blue strip there though... those are the things I'm supposed to forget.
Last edited by mendhak; Aug 6th, 2004 at 12:34 AM.
Thanks for the screen shot and the tips (you too nemaroller).
I will have to try out this Firefox. I should probably get Netscape as well, to make sure everything works for that browser too. I also need to complete two other VB programs I am currently writing. Create my company's website. Investigate SharePoint Services for a client. Fix that Chamber site. Learn .NET.
To hell with it. Saturday morning I'm off to the other coast for a weeks R & R. Where are you from?
From way too many places, but that's an extremely long story. I've lived most of my life in Vancouver, so it's the closest thing I've got to a home. Kingsway & Boundary, Burnaby Heights, Kamloops... *sigh*