Here is all of the code:
when the page loads - it first displays a list of buttons on the
left side of the page - then once a user selects one of the buttons
the 2 datalists and datagrids are then populated.
thanks for any help!
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If (Not (Page.IsPostBack)) Then
lblLocation.Text = Request.QueryString("location")
lblMsg.Visible = True
lblCatName.Visible = True
End If
End Sub
Sub Getdgdata()
Try
Dim dtprograms = DataHelper.GetAllActivitiesAndUsers
(busID, locID)
BindGrid(dtprograms)
Catch ex As Exception
Throw New Exception("Get Process Activity List failed",
ex)
End Try
End Sub
Sub Getdldata()
'Dim locID As Integer = Request.QueryString("LID")
'Dim iloc As Integer = Convert.ToInt32(locID)
Try
Dim dtUserHours = DataHelper.GetUserHours()
Dim dvw_userHours = New DataView(dtUserHours)
dvw_userHours.RowFilter = "LocationID=" & locID & " and
per_inactiveID =0"
Dim r As DataRowView
BindDlst(dvw_userHours)
Catch ex As Exception
Throw New Exception("Get User hours failed", ex)
End Try
End Sub
Public Function Getddldata()
Dim dtnames As DataTable
Try
dtnames = DataHelper.GetUsers(busID, locID)
Catch ex As Exception
Throw New Exception("Get Names List failed", ex)
End Try
Dim r As DataRow
r = dtnames.NewRow
r(0) = 0 'PersonID
r(1) = 0 'businessID
r(2) = 0 'locationID
r(3) = "" 'FirstName
r(4) = "" 'LastName
r(5) = "" 'Title
r(6) = 0 'Per_StatusID
r(7) = 0 'Per_InactiveID
dtnames.Rows.Add(r)
Dim dvw_names As New DataView(dtnames)
dvw_names.RowFilter = "per_inactiveID= 0"
Return dvw_names
End Function
Private Sub BindGrid(ByVal dtAssignedActivity As DataTable)
Dim dvw_PgmActivities As New DataView(dtAssignedActivity)
dgAssignedActivity.DataSource = dvw_PgmActivities
dvw_PgmActivities.RowFilter = ("Act_SubCategoryID =" &
lblSubCatID.Text)
dgAssignedActivity.DataBind()
End Sub
Private Sub BindDlst(ByVal dvw_UserHours As DataView)
'dvw_UserHours.RowFilter = ("Act_SubCategoryID =" &
lblSubCatID.Text)
dlstUserHours.DataSource = dvw_UserHours
dlstUserHours.DataBind()
lblDtList.Text = "Employee/Hours:"
End Sub
Private Sub dgAssignedActivity_EditCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Handles dgAssignedActivity.EditCommand
prevpersonID = CType(e.Item.FindControl("lblUserID"),
Label).Text
'Sets the dropdown list to the selected value when in edit
mode
strName = CType(e.Item.FindControl("lblName"), Label).Text
'Identify whether there is any user selected for this
activity and store the name for use
'when updating user activities
lblName.Text = strName
lblPrevUserid.Text = prevpersonID
dgAssignedActivity.EditItemIndex = e.Item.ItemIndex
Dim dtAssignedActivity = DataHelper.GetAllActivitiesAndUsers
(busID, locID)
BindGrid(dtAssignedActivity)
End Sub
Private Sub dgAssignedActivity_CancelCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Handles dgAssignedActivity.CancelCommand
dgAssignedActivity.DataKeyField = "personID"
dgAssignedActivity.EditItemIndex = -1
Dim dtAssignedActivity = DataHelper.GetAllActivitiesAndUsers
(busID, locID)
BindGrid(dtAssignedActivity)
End Sub
Private Sub dgAssignedActivity_UpdateCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Handles dgAssignedActivity.UpdateCommand
Dim strName As String = CType(e.Item.FindControl("ddlName"),
DropDownList).SelectedValue
Dim intActivityID As Integer = CType(e.Item.FindControl
("lblactivityID"), Label).Text
Dim sHours As String = CType(e.Item.FindControl("lblHours"),
Label).Text
Dim dHours As Decimal = CDec(sHours)
Dim sprevpersonID As String = lblPrevUserID.Text
If lblName.Text = "" Then
Dim drUserActivity = DataHelper.InsertUserActivity
(strName, intActivityID, dHours)
dgAssignedActivity.EditItemIndex = -1
Getdgdata()
Else
Dim drUserActivity = DataHelper.UpdateUserActivity
(strName, intActivityID, sprevpersonID)
dgAssignedActivity.EditItemIndex = -1
Getdgdata()
End If
Getdldata()
End Sub
Private Sub btnEnergy_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Dim subCatName As String
lblSubCatID.Text = 8
subCatName = "Energy"
lblMsg.Visible = False
Try
Getdgdata()
lblSubCat.Text = subCatName
Catch ex As Exception
Throw New Exception("Get Energy Activity List failed",
ex)
End Try
lblSubCat.Text = subCatName
Getdldata()
End Sub
Public Sub SetDropDownIndex(ByVal sender As Object, ByVal e As
System.EventArgs)
'Sets the dropdown list to the selected value when in edit
mode
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText
(strName))
End Sub
Private Sub btnAcctAudit_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnAcctAudit.Click
Response.Redirect("..\..\accountaudit.aspx?business=" +
Server.UrlEncode(Request.QueryString("business")) + "&BID=" +
Server.UrlEncode(Request.QueryString("BID")) + "&location=" +
Server.UrlEncode(Request.QueryString("location")) + "&LID=" +
Server.UrlEncode(Request.QueryString("LID")))
End Sub
Private Sub btnBagWarehouse_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnBagWarehouse.Click
Dim subCatName As String
lblSubCatID.Text = 18
subCatName = "Bag Warehousing"
lblMsg.Visible = False
Try
Getdgdata()
lblSubCat.Text = subCatName
Catch ex As Exception
Throw New Exception("Get Bag Warehouse Activity List
failed", ex)
End Try
lblSubCat.Text = subCatName
Getdldata()
End Sub
Private Sub btnblocks_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnblocks.Click
Dim subCatName As String
lblSubCatID.Text = 23
subCatName = "Blocks"
lblMsg.Visible = False
Try
Getdgdata()
lblSubCat.Text = subCatName
Catch ex As Exception
Throw New Exception("Get Blocks Activity List failed",
ex)
End Try
lblSubCat.Text = subCatName
Getdldata()
End Sub
Private Sub btnBulkLoadOut_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnBulkLoadOut.Click
Dim subCatName As String
lblSubCatID.Text = 19
subCatName = "Bulk Loadout"
lblMsg.Visible = False
Try
Getdgdata()
lblSubCat.Text = subCatName
Catch ex As Exception
Throw New Exception("Get Bulk Loadout Activity List
failed", ex)
End Try
lblSubCat.Text = subCatName
Getdldata()
End Sub
Private Sub btnBulkReceiving_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnBulkReceiving.Click
Dim subCatName As String
lblSubCatID.Text = 12
subCatName = "Bulk Receiving"
lblMsg.Visible = False
Try
Getdgdata()
lblSubCat.Text = subCatName
Catch ex As Exception
Throw New Exception("Get Bulk Receiving Activity List
failed", ex)
End Try
lblSubCat.Text = subCatName
Getdldata()
End Sub
End Class
--- In [email protected], Dean Fiala
<[EMAIL PROTECTED]> wrote:
> Let's see all your code. My guess is that you can control your
> postback handling and get the results you want, it is very common
to
> have multiple controls with separate data sources on a single page.
>
> On 6/1/05, kstrader2002 <[EMAIL PROTECTED]> wrote:
> > I have 2 datalists and a datagrid on one page. I am using
> > databinder.eval to retrieve the necessary values when the
controls
> > are bound to the database. Each of the controls requires a
separate
> > stored procedure to retrieve the correct data for the control -
I am
> > unable to combine them into a single stored procedure. The
problem
> > I am running into is that if for instance the first control
displays
> > name and total hours and the second control displays activity and
> > hours - it causes an error on the first control because after
> > evaluating the second control it will say that "name" does not
exist
> > in the dataview - which is being caused because it is rebinding
the
> > first datalist when it binds for the second datalist control.
How
> > do I get each control to only bind for the data they are targeted
> > for?
> >
> > Here is the code for my 2 datalists - there is also a datagrid
which
> > I did not include:
> > <P><asp:label id="lblDtList" runat="server" Font-
> > Bold="True"></asp:label></P>
> > <asp:datalist id="dlstUserHours" runat="server" Width="752px"
> > RepeatColumns="2">
> > <ItemStyle HorizontalAlign="Left" Width="450px"></ItemStyle>
> > <ItemTemplate>
> > <TABLE height="25">
> > <TR>
> > <TD width="20%"></TD>
> > <TD width="50%"><%# Databinder.Eval(Container,"DataItem.Name")
></TD>
> > <TD width="10%"> <%# Databinder.Eval
> > (Container,"DataItem.SuppAct_Hours") %></TD>
> > <TD width="20%"></TD>
> > </TR>
> > </TABLE>
> > </ItemTemplate>
> > </asp:datalist></TD>
> > <TD height="115"></TD>
> > </TR>
> > <tr>
> > <TD vAlign="top" width="70%" height="115">
> > <P><asp:label id="lblDtListActivity" runat="server" Font-
> > Bold="True"></asp:label></P>
> > <asp:datalist id="dlstActivity" runat="server" Width="752px">
> > <ItemStyle HorizontalAlign="Left" Width="450px"></ItemStyle>
> > <ItemTemplate>
> > <TABLE height="25">
> > <TR>
> > <TD width="20%"></TD>
> > <TD width="50%"><%#
> > Databinder.EvalContainer,"DataItem.ActivityName") %></TD>
> > <TD width="10%"> <%# Databinder.Eval
> > (Container,"DataItem.suppAct_hours") %></TD>
> > <TD width="20%"></TD>
> > </TR>
> > </TABLE>
> > </ItemTemplate>
> > </asp:datalist></TD>
> > <TD height="115"></TD>
> > </tr>
> > <TR>
> >
> > Here is the corresponding databinding routines:
> > Sub Getdldata()
> > 'Dim locID As Integer = Request.QueryString("LID")
> > 'Dim iloc As Integer = Convert.ToInt32(locID)
> > Try
> > Dim dtUserHours = DataHelper.GetUserHours()
> > Dim dvw_userHours = New DataView(dtUserHours)
> > dvw_userHours.RowFilter = "LocationID=" & locID & "
and
> > per_inactiveID =0"
> > Dim r As DataRowView
> > BindDlst(dvw_userHours)
> > Catch ex As Exception
> > Throw New Exception("Get User hours failed", ex)
> > End Try
> >
> > End Sub
> >
> > Sub GetdlActivitydata()
> > Try
> > Dim dtLocActivity =
DataHelper.GetAllActivitiesAndUsers
> > Dim dvw_LocActivity = New DataView(dtLocActivity)
> > dvw_LocActivity.RowFilter = "Act_SubCategoryID = 24"
> > BindActivityDlst(dvw_LocActivity)
> > Catch ex As Exception
> > Throw New Exception("Get People Activity List
failed",
> > ex)
> > End Try
> >
> > End Sub
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/