Greetings.
I have a serious problem. I have multiple sets of tables, several of
which are chained more than two tables deep. That is, I have a parent, a
child, and a great-grandchild table.
Currently, I am allowing the parent to be edited by itself. In order to
get to a child table, a user needs to select a specific parent table ID.
I have set this up using panels, and putting a drop-down list in the
first panel, with its contents drawn from the parent table. When the
user selects a parenttable.name, the correct parenttable.ID is sent to
the next iteration of the page, where it is used as the
childtable.parentID reference to populate the datagrid.
My main problem is when there are no child table entries for that parent
table ID. Without any entries, the "add entry" value for
childtable.parentID cannot be filled, because nothing is being drawn
from the database.
Below is the code that I have tried to implement so far:
Sub ddlSelectRegion_Click(sender As Object, e As EventArgs)
Dim iRegionID as String
iRegionID = ddlSelectRegion.SelectedValue
Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings( "strConn"))
Dim myCmd as New OleDbCommand("SELECT * FROM tblCarClubInfo WHERE
[CarClubRegionID] = " & iRegionID & " ORDER BY [ID]", myConn)
myConn.Open()
dgCarClubInfo.DataSource =
myCmd.ExecuteReader(CommandBehavior.CloseConnectio n)
Dim ltrRegionID as Literal
ltrRegionID.Text = ddlSelectRegion.SelectedValue
dgCarClubInfo.DataBind()
myConn.Close()
End Sub
On the submission of the drop-down list's button, the selected value
gets extracted, and used in the SQL statement. However, if it is empty,
I need to pass that value on to the correct column in the datagrid. I
have tried to use a literal (<asp:literal /> - it uses no HTML), but the
fourth to last line always throws an error (Object reference not set to
an instance of an object). In order to populate the literal, this line
must work. That way, I can populate the "add" row's "ParentID" field
with the literal, so any additions will have the ParentID it requires.
Another problem is that I need to make this literal population fire only
when the database doesn't return any results. I have tried to find the
ASP.NET equivelents to the old rs.EOF rs.BOF methods, without success.
Any suggestions?
On another note, are there any tutorials that can show how I can have a
parent/child/grandchild/greatgrandchild datagrid (or close enough) with
every table being editable, deletable, and addable from within the same
datagrid? That is, you have "edit", "delete" and "add" buttons for every
layer of the datagrid.
TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************