I have a page with a detailsView that allows the user to add a project. Once the project is added, there are several gridViews that contain information related to the ProjectID that is created in the detailsView. The one I'm having trouble with is the resources gridView. The user can go into the page, create a project, and then should be able to create resource records based on the ProjectID. I've got the Add and Delete functionality working fine but when I click the 'Edit' button on the gridView nothing happens (the edit templates don't appear). I did this on another page and it works fine but for some reason it won't gel here. I'm pretty sure it has something to do with databinding but I'm stumped. Here's my code:
DetailsView:
<asp:DetailsView
ID="dvProjectDetails"
DataSourceID="dsProjectDetails"
DataKeyNames="ProjectID"
Width="100%"
AutoGenerateRows="False"
runat="server">
<Fields>
<asp:TemplateField HeaderText="Project ID" HeaderStyle-Width="110px" HeaderStyle-CssClass="bold_8" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblProjectID" Text='<%# Eval("ProjectID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Project Name" HeaderStyle-Width="110px" HeaderStyle-CssClass="bold_8" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblProjectName" Text='<%# Eval("ProjectName") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtProjectName" Text='<%# Bind("ProjectName") %>' Width="250px" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
</asp:DetailsView>
Its datasource:
<asp:SqlDataSource
ID="dsProjectDetails"
ConnectionString="<%$ ConnectionStrings:BOS %>"
SelectCommand="up_ProjectDetailsSelect"
SelectCommandType="storedprocedure"
UpdateCommand="up_ProjectUpdate"
UpdateCommandType="StoredProcedure"
runat="server">
<SelectParameters>
<asp:Parameter Name="ProjectID" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ProjectID" Type="Int32" />
</InsertParameters>
The addResource code:
Protected Sub btnAddResource_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddResource.Click
Dim sFullName, sLname, sFname, sNBID As String
Dim iFullNameLen, iCommaPos, iDashPos, iResourceID As Integer
sFullName = txtResourceSearch.Text
iFullNameLen = Len(sFullName)
iCommaPos = InStr(sFullName, ",")
If iCommaPos > 0 Then
iDashPos = InStr(sFullName, "-")
If iDashPos > 0 Then
sLname = Trim(Left(sFullName, (iCommaPos - 1)))
sFname = Trim(Mid(sFullName, (iCommaPos + 1), (iDashPos - 1) - iCommaPos))
sNBID = Trim(Right(sFullName, iFullNameLen - iDashPos))
Dim oConn As New SqlConnection(DataProvider.GetConnectionString)
Dim oCmd As New SqlCommand
oConn.Open()
With oCmd
.Connection = oConn
.CommandType = CommandType.StoredProcedure
.CommandText = ("up_ResourceIDSelect")
.Parameters.Add("@NBID", SqlDbType.VarChar).Value = sNBID
iResourceID = .ExecuteScalar()
.Parameters.Clear()
.CommandText = ("up_ProjectResourceAssignmentInsert")
.Parameters.Add("@ResourceID", SqlDbType.SmallInt).Value = iResourceID
.Parameters.Add("@ProjectID", SqlDbType.SmallInt).Value = dvProjectDetails.SelectedValue
.Parameters.Add("@ProjectRoleID", SqlDbType.VarChar).Value = ddlRoleAdd.SelectedValue
.ExecuteNonQuery()
End With
oConn.Close()
dsResources.SelectParameters(0).DefaultValue = dvProjectDetails.SelectedValue
gvResources.DataBind()
txtResourceSearch.Text = ""
End If
End If
End Sub
Thanks in advance,
N
AutoGenerateEditButton="Tr
Bob