Hello,
I have two Datagrids on my Page: Company(Parent) and User(Child). I load all users belonging to a company on a child grid. How can I select a particular user?
HTML-Code for Datagrid:
<asp:datagrid id="dgCompany" runat="server" AutoGenerateColumns="False" OnItemCommand="dgCompanyItem">
<Columns>
<asp:TemplateColumn HeaderText="DETAILS">
<ItemTemplate>
<asp:ImageButton id="btnUser" CommandName="show" ImageUrl="images/add.gif" runat="server"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
+++
...and more columns....
+++
<asp:TemplateColumn>
<ItemTemplate>
<tr>
<td colspan="5">
<asplaceHolder id="plcDG" Runat="server">
</asplaceHolder>
</td>
</tr>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
Codebehind for button click:
Sub dgCompanyItem(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs) Handles dgCompany.ItemCommand
If E.CommandName = "show" Then
Dim tmpdg As New DataGrid()
tmpdg.AutoGenerateColumns = False
Dim colButton As New ButtonColumn()
colButton.ButtonType = ButtonColumnType.PushButton
colButton.HeaderText = "SELECT"
colButton.Text = "Select"
colButton.CommandName = "Select"
Dim colID As New BoundColumn()
colID.DataField = "id"
colID.HeaderText = "ID"
Dim colLogonname As New BoundColumn()
colLogonname.DataField = "logonname"
colLogonname.HeaderText = "LOGONNAME"
Dim colDepartment As New BoundColumn()
colDepartment.DataField = "department"
colDepartment.HeaderText = "DEPARTMENT"
tmpdg.Columns.Add(colButton)
tmpdg.Columns.Add(colID)
tmpdg.Columns.Add(colLogonname)
tmpdg.Columns.Add(colDepartment)
Me.daUser.SelectCommand.CommandType = CommandType.StoredProcedure
Me.daUser.Fill(dsUser, "user"
tmpdg.DataSource = Me.dsUser.Tables("user".DefaultView
tmpdg.DataBind()
E.Item.FindControl("plcDG".Controls.Add(tmpdg)
End If
End Sub
***
How can I ascertain wich user was selected
I have two Datagrids on my Page: Company(Parent) and User(Child). I load all users belonging to a company on a child grid. How can I select a particular user?
HTML-Code for Datagrid:
<asp:datagrid id="dgCompany" runat="server" AutoGenerateColumns="False" OnItemCommand="dgCompanyItem">
<Columns>
<asp:TemplateColumn HeaderText="DETAILS">
<ItemTemplate>
<asp:ImageButton id="btnUser" CommandName="show" ImageUrl="images/add.gif" runat="server"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
+++
...and more columns....
+++
<asp:TemplateColumn>
<ItemTemplate>
<tr>
<td colspan="5">
<asplaceHolder id="plcDG" Runat="server">
</asplaceHolder>
</td>
</tr>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
Codebehind for button click:
Sub dgCompanyItem(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs) Handles dgCompany.ItemCommand
If E.CommandName = "show" Then
Dim tmpdg As New DataGrid()
tmpdg.AutoGenerateColumns = False
Dim colButton As New ButtonColumn()
colButton.ButtonType = ButtonColumnType.PushButton
colButton.HeaderText = "SELECT"
colButton.Text = "Select"
colButton.CommandName = "Select"
Dim colID As New BoundColumn()
colID.DataField = "id"
colID.HeaderText = "ID"
Dim colLogonname As New BoundColumn()
colLogonname.DataField = "logonname"
colLogonname.HeaderText = "LOGONNAME"
Dim colDepartment As New BoundColumn()
colDepartment.DataField = "department"
colDepartment.HeaderText = "DEPARTMENT"
tmpdg.Columns.Add(colButton)
tmpdg.Columns.Add(colID)
tmpdg.Columns.Add(colLogonname)
tmpdg.Columns.Add(colDepartment)
Me.daUser.SelectCommand.CommandType = CommandType.StoredProcedure
Me.daUser.Fill(dsUser, "user"
tmpdg.DataSource = Me.dsUser.Tables("user".DefaultView
tmpdg.DataBind()
E.Item.FindControl("plcDG".Controls.Add(tmpdg)
End If
End Sub
***
How can I ascertain wich user was selected