W
who be dat?
I need some help here. I'm creating a list on a page where the list is
created from a dataset with two tables linked with a datarelation. The
first table is a list of groups while the second table is a list of items in
that group. I want to show these items in what would basically look a lot
like a tree view. I decided to just show everything in a placeholder
control on an aspx form. First, I display a groupname from the first table
by creating a literalcontrol. Then, under the groupname I display all the
items that go along with that group in a list. For each group, I repeat
this (see code below). All this is done in a page load event. Thing is,
each item in a group's list is a linkbutton. I need to be able to detect
when a given linkbutton is clicked, put an item assigned in the linkbutton's
commandargument property in a session object, then redirect the browser to
another page. Thing is, I am unable to execute code when one of these
linkbuttons are clicked. Any ideas on how I can do this? If this isn't the
best way to do this, please let me know how. Some example code or a link to
a website with a sample and code would be great. I tried to think of a way
to do this by having a datagrid with a datalist control in each cell where
the groupname would be listed in the cell and the items would show up in the
datalist as linkbuttons. I couldn't quite get it to work. Below is the
code I'm currently using to attempt this. The controls are inserted into a
placeholder control in the form. I didn't include the aspx code as it's
fairly straight forward. If it's needed, just let me know. Thanks!!
Chris Smith
begin code -----
....code snipped which pulls data from SQL Server tables and stores them in
datatables....
dsForum.Relations.Add("groupid_relation", _
dsForum.Tables("Grouplist").Columns(0), _
dsForum.Tables("ForumList").Columns(0))
For Each rowGroup In dsForum.Tables("groupList").Rows
plhPlaceHolder.Controls.Add(New LiteralControl("<P>"))
plhPlaceHolder.Controls.Add(New LiteralControl(CStr(rowGroup(1))))
For Each rowForum In rowGroup.GetChildRows("Groupid_relation")
Dim link As New LinkButton
link.Text = Trim(CStr(rowForum(2)))
link.CommandArgument = CStr(rowForum(1))
plhPlaceHolder.Controls.Add(New LiteralControl("<BR><LI>"))
plhPlaceHolder.Controls.Add(link)
Next
plhPlaceHolder.Controls.Add(New LiteralControl("</P>"))
Next
created from a dataset with two tables linked with a datarelation. The
first table is a list of groups while the second table is a list of items in
that group. I want to show these items in what would basically look a lot
like a tree view. I decided to just show everything in a placeholder
control on an aspx form. First, I display a groupname from the first table
by creating a literalcontrol. Then, under the groupname I display all the
items that go along with that group in a list. For each group, I repeat
this (see code below). All this is done in a page load event. Thing is,
each item in a group's list is a linkbutton. I need to be able to detect
when a given linkbutton is clicked, put an item assigned in the linkbutton's
commandargument property in a session object, then redirect the browser to
another page. Thing is, I am unable to execute code when one of these
linkbuttons are clicked. Any ideas on how I can do this? If this isn't the
best way to do this, please let me know how. Some example code or a link to
a website with a sample and code would be great. I tried to think of a way
to do this by having a datagrid with a datalist control in each cell where
the groupname would be listed in the cell and the items would show up in the
datalist as linkbuttons. I couldn't quite get it to work. Below is the
code I'm currently using to attempt this. The controls are inserted into a
placeholder control in the form. I didn't include the aspx code as it's
fairly straight forward. If it's needed, just let me know. Thanks!!
Chris Smith
begin code -----
....code snipped which pulls data from SQL Server tables and stores them in
datatables....
dsForum.Relations.Add("groupid_relation", _
dsForum.Tables("Grouplist").Columns(0), _
dsForum.Tables("ForumList").Columns(0))
For Each rowGroup In dsForum.Tables("groupList").Rows
plhPlaceHolder.Controls.Add(New LiteralControl("<P>"))
plhPlaceHolder.Controls.Add(New LiteralControl(CStr(rowGroup(1))))
For Each rowForum In rowGroup.GetChildRows("Groupid_relation")
Dim link As New LinkButton
link.Text = Trim(CStr(rowForum(2)))
link.CommandArgument = CStr(rowForum(1))
plhPlaceHolder.Controls.Add(New LiteralControl("<BR><LI>"))
plhPlaceHolder.Controls.Add(link)
Next
plhPlaceHolder.Controls.Add(New LiteralControl("</P>"))
Next