The first pair displays (gridview) and allows editing (detailsview) of the projects a user is assigned. If the user is assigned Admin to the project then they can edit the project otherwise they can view the tasks (2nd pairing of GridView/DetailsView) assigned to them within the project.
The second pair of controls will either allow the user to edit 2 fields or edit the editable fields of a task. Basically, if a user is Admin to the project they can edit all editable fields within the Tasks Details View. But if they have merely been assigned a task within the project then they can only edit 2 fields (comments and status) of the task.
The problem:
As Admin to the project, if i select a project to view its list of tasks and their have been no tasks created (new project), then it brings up the Tasks Details View in Insert mode and i can start inserting data into the detailsview and insert into the database. If the project has tasks and i want to view the tasks details then it shows the details and the editable fields, as it should for both processes. The problem is if i look at a task for a project (in ReadOnly mode) and then want to view the tasks of a project that does not have any tasks yet, it throws a NullReferenceException error at the line posted below:
CType(dvwUserTask.FindControl("cboINSTaskPName"), DropDownList).SelectedValue = tmpPID
I have segregated the code some to help with the debugging but it hasnt changed the error.
If tblProjTasks.Count <= 0 Then
If (gvwUserProjects.Rows(selIndex).Cells(3).Text = Session("userid").ToString) Or (gvwUserProjects.Rows(selIndex).Cells(4).Text = Session("userid").ToString) Then
dvwUserTask.ChangeMode(DetailsViewMode.Insert)
Dim tmpPID As Integer = CType(gvwUserProjects.Rows(selIndex).Cells(2).Text, Integer)
CType(dvwUserTask.FindControl("cboINSTaskPName"), DropDownList).SelectedValue = tmpPID
CType(dvwUserTask.FindControl("lblINSTaskTID"), Label).Text = 1
dvwUserTask.Visible = True
End If
Else
gvwUserProjTasks.DataSource = tblProjTasks
gvwUserProjTasks.DataBind()
gvwUserProjTasks.Visible = True
End If
Design:
I have setup the Gridview(GV) as a readonly interface and the DetailsView(DV) as the main editing interface. The GV & DV are in HTML tables and i have 2 tables, one for Projects and one for Tasks. Both DV controls have a ReadOnly, Edit, and Insert Control Template structure. The problem is directly related to the Tasks DV and not the Projects DV. Seems it is having problems going from the RO mode to the INS mode.
Debugging:
I have verified that the name of the control in the INS mode is correct, which it is cause if i do the INS mode first it brings up the DV properly with no error. But it only shows up when i go from RO mode to INS mode. As you can see in the code segment above, i change the mode to INS before i make the reference to the control.
Update to problem
When i comment out the NullReferenceException line above it works correctly, when going from a Project View RO in the DV to another Project Insert in the DV.
If tblProjTasks.Count <= 0 Then
If (gvwUserProjects.Rows(selIndex).Cells(3).Text = Session("userid").ToString) Or (gvwUserProjects.Rows(selIndex).Cells(4).Text = Session("userid").ToString) Then
dvwUserTask.ChangeMode(DetailsViewMode.Insert)
'Dim tmpPID As Integer = CType(gvwUserProjects.Rows(selIndex).Cells(2).Text, Integer)
'CType(dvwUserTask.FindControl("cboINSTaskPName"), DropDownList).SelectedValue = tmpPID
CType(dvwUserTask.FindControl("lblINSTaskTID"), Label).Text = 1
dvwUserTask.Visible = True
End If
Else
This post has been edited by woodjom: 20 July 2009 - 12:54 PM

New Topic/Question
Reply




MultiQuote





|