In brief (more detailled information below): A DetailView gets a dataset (employee data) from an SQLDataSource. Some of the columns (employee's boss, employee's department manager, etc.) I want to have a link which then link to other datasets (the boss's detailled data etc.) (to be displayed in a DetailsView, too).
Can anyone help how to realize that in ASP.Net?
Detailled description:
I am writing a small and actually very simple module for DotNetNuke which displays data from our HR database. The module consists of one ASCX file with a multiview and following views:
- View 1 shows a GridView with an employee list which is set to selectable. If an employee row is selected View 2 is displayed:
- View 2 shows a DetailsView with an employee's detailled data.
- View 3 shows a GridView with an job list which is set to selectable. If a job is selected View 4 is displayed:
- View 4 shows a DetailsView with the job details.
In the job details several employees occur: The employee who is doing that job, an employee who is assigned as his boss and maybe an employee who is the department manager (might be the same person). Therefore I would like to have a link from these employees back to the View 2 with the DetailsView and the employee details.
My approach so far was:
- Template field with an <asp:LinkButton runat="server" onclick="ShowEmployeeDetails" Text='<%# Eval("[Supervisor]") %>'></asp:LinkButton>
- When LinkButton is clicked: Show View 2 and fille the DetailsView with that employees data
Now I have two issues:
- When the Text=... property of the LinkButton is databound (instead of some static text) then rendering the page throws an error: A critical error has occurred. Exception has been thrown by the target of an invocation.
- When the LinkButton is clicked, View 2 shows but only the Label on top shows the correct employees name. But the DetailsView itself does not show.
Code:
1 protected void ShowEmployeeDetails(object sender, System.EventArgs e)
2 {
3 EmployeeListGrid.SelectedIndex = 3; // GridView on View 1 with employee list, eid=3 is for testing
4 EmployeeDetailData.DataBind(); // the SQLDataSource for getting employee details
5 EmployeeProfile.DataBind(); // the DetailsView for displaying employee details
6 employeeSQLViews.ActiveViewIndex = 1; // show the view with the employee details
7 }
1 protected void EmployeeProfile_DataBound(object sender, System.EventArgs e)
2 {
3 if (EmployeeListGrid.SelectedRow != null) {
4 SelectedEmployeeLabel.Text = System.Convert.ToString(EmployeeListGrid.SelectedRow.Cells[1].Text);
5 EmployeeListGrid.SelectedIndex = -1;
6 }
7 }