nested datagrids

S

Sue

Help! Using nested datagrids in web app using VStudio 2003, IIS, SQLServer.
Got the data to load just find in both the outer and inner datagrids. I need
to capture a "select" button click in the inner datagrid, pull the value of
the button text from the clicked
button, and use the value to call a sub to populate controls further down in
the page. I've tried adding
a handler to the inner datagrid to capture the button click, wired up the
ItemCommand in the web server control
in the html page (e.g. onItemCommand="DG_Employee_ItemCommand(... handles
DG_Employee.ItemCommand), and
tried assigning it in the outer DG_OnItemDataBound sub (see code below)
without success. The page does a
postback, but nothing happens. I've debugged this page to a fare-thee-well
and am ready to throw the
computer out the window. I know I'm missing something simple, but can't
identify it. Anyone have a clue?
HTML snip and code-behind snips below...

tia,
Sue, the frustrated

' snip of html page

<asp:datagrid id="DG" Runat="server" Width="100%">
<Columns>
<asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"
DataTextField="PositionID" Visible="false" />
<asp:BoundColumn DataField="PositionNumber"
SortExpression="PositionNumber" HeaderText="Pos No" />
<asp:BoundColumn DataField="PositionDepartmentDescription"
SortExpression="PositionDepartmentDescription"
HeaderText="Dept" />
<asp:TemplateColumn>
<ItemTemplate>
<asp:DataGrid ID="DG_Employee" Runat="server" Width="100%">
<Columns>
<asp:ButtonColumn ButtonType= "PushButton" CommandName="Select"
DataTextField="EmployeeID" />
<asp:BoundColumn ItemStyle-Width="25%" DataField="Name"
HeaderText="Name" />
<asp:BoundColumn itemstyle-width="25%"
DataField="DepartmentDescription" HeaderText="Dept" />
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

' code behind page

Private Sub DG_ItemDataBound(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles DG.ItemDataBound

Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem,
ListItemType.SelectedItem
Dim button As LinkButton =
CType(e.Item.Cells(0).Controls(0), LinkButton)
e.Item.Cells(1).Attributes("onclick") =
Page.GetPostBackClientHyperlink(button, "")
e.Item.Cells(2).Attributes("onclick") =
Page.GetPostBackClientHyperlink(button, "")
e.Item.Attributes.Add("onmouseover",
"javascript:this.style.cursor='hand';")


Dim Details_DG As DataGrid
Details_DG = CType(e.Item.Cells(3).Controls(1), DataGrid)

AddHandler Details_DG.ItemCommand, AddressOf
DG_Employee_ItemCommand

Details_DG.AutoGenerateColumns = False

Dim SQLOps As New SQLOperations

Dim DGE_DS As New DataSet

' this function returns a dataset
DGE_DS = SQLOps.SQLReturnDataSet("select * from detail
where ID=" & someID)
' & " and recordstatus = 'Active' order by Name")
SQLOps = Nothing

Details_DG.DataSource = DGE_DS
Details_DG.DataBind()
end select

end sub


Private Sub DG_ItemCommand(ByVal source As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG.ItemCommand
If Not e.CommandName = "Page" Then
If e.CommandName = "Select" Then
Session("ThisPositionID") =
CType(CType(e.Item.Cells(0).Controls(0), System.Web.UI.Control),
LinkButton).Text
Call LoadPositionInfo()
End If
End If
End Sub

Private Sub DG_Employee_ItemCommand(ByVal source As System.Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DG_Employee.ItemCommand
If Not e.CommandName = "Page" Then
If e.CommandName = "Select" Then
Session("ThisEmployeeID") =
CType(CType(e.Item.Cells(0).Controls(0), System.Web.UI.Control),
LinkButton).Text
Call LoadEmployeeInfo()
End If
End If
End Sub
 
S

Sue

I've got an MSDN subscription and thought these posts would be answered
within 24 hours. Am I misinformed? Posted this in the wrong group? Or?

Sue
 
S

Sue

Yes, the MSDN email address is associated with the newgroup email address -
and I've used it several times in the past without problems. I should have
clarified the "Anyone awake" as specifically targeting MS support staff -
sorry. And, I think part of my message is also incorrect - the response
period is 2 business days - so says the main managed newgroups web page -
right in plain sight which is why I probably missed it <g>. Oy....

regards!
Sue

Alvin Bruney - ASP.NET MVP said:
is your msdn email associated with the newsgroup email address that u use?
Microsoft is the only party responsible for honoring that 24 hour request by
the way.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Sue said:
I've got an MSDN subscription and thought these posts would be answered
within 24 hours. Am I misinformed? Posted this in the wrong group? Or?

Sue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top