473,734 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid EditCommandColu mn not firing events properly.

Hello all, I hope all is well with you.

I am having a seriously difficult time with this problem. Allow me to
set
up the problem.

I have a System.Web.UI.P age with the following controls (watch the
layout,
some have child controls):

1. DataGrid (dgContracts) - Lists current contracts.
1.1. ButtonColumn (CommandName SelectContract) - Selects a contract
to
use.
2. Repeater (rptrJobActivit ies) - Lists all Job Activities for a
Contract/Job when a user selects a contract from

dgContracts. Each RepeaterItem represents a single JobActivity.
2.1. DropDownList (ddlInstallers <asp:DropDownLi st
ID="ddlInstalle rWorkers" DataSource='<%#

InstallerWorker s()%>' DataTextField=" FullName"
DataValueField= "WorkerId"
Runat="server" />) Lists all available

Installers (people)
2.2. Button (btnAddInstalle r <asp:Button CssClass="submi t"
ID="btnAddInsta ller" Text="Add"

OnClick="btnAdd Installer_Click "

Runat="server" />) Adds the selected installer in ddlInstallers to the
JobActivityInst allers collection.
2.3. DataGrid (dgInstallers <asp:DataGrid
ID="dgJobActivi tyInstallers"
AutoGenerateCol umns="False"

Width="75%" Runat="server"> )

Displays the installers that are added to the job activity
(AddHandlers to
EditCommand, CancelCommand and

UpdateCommand in

rptrJobActiviti es_ItemCreated - NOTE: Originally I had these assigned
in
the <asp:DataGrid

OnEditCommand=" dgInstallers_Ed itCommand"
OnCancelCommand ="dgInstallers_ CancelCommand"

OnUpdateCommand ="dgInstallers_ UpdateCommand"/> until this problem came
up)
2.3.1. EditCommandColu mn (<asp:EditComma ndColumn
ButtonType="Lin kButton"
CancelText="Can cel"

EditText="Edit"

UpdateText="Upd ate"/>)
A user will load this page, dgContracts is DataBind only on Not
IsPostback,
select a contract from dgContracts, by

clicking the ButtonCol The page posts, dgContracts_Ite mCommand fires -
rpterJobActivit ies is DataBind, and

rptrJobActiviti es is populated with all the Job Activities associated
with
the selected contract. Everytime

rptrJobActiviti es_ItemCreated is fired dgInstallers is DataBind and
AddHandlers are assigned for each EditCommand,

CancelCommand and UpdateCommand (DataBind THEN AddHandlers)

Inside each Job Activity, repeater item, basic data is displayed and
dgInstallers is populated with Installers

working on this Job Activity.

The user is permitted to add new installers by selecting ddlInstallers
and
clicking btnAddInstaller . The page posts

and the newly added installer appears in dgInstallers.
btnAddInstaller _Click is fired and code adds to the

collection of installers.

Everything seems to work just fine up to this point.

Now, when you click the EditCommandColu mn 'Edit' Link it calls
dgInstallers_Ed itCommand, we set the edit index and

then DataBind. All well and good. When we click the EditCommandColu mn
"Cancel", the page just posts. No event is

fired. If we instead click the EditCommandColu mn "Update" link,
dgInstallers_Ed itCommand is fired once again.

When we hover the mouse over the Edit link, the actual link is:

javascript:__do PostBack('rptrJ obActivities$_c tl0$dgJobActivi tyInstallers$_c tl2$_ctl0','')

When we hover the mouse over the Cancel link, the actual link is:

javascript:__do PostBack('rptrJ obActivities$_c tl0$dgJobActivi tyInstallers$_c tl2$_ctl1','')

When we hover the mouse over the Update link, the actual link is:
javascript:__do PostBack('rptrJ obActivities$_c tl0$dgJobActivi tyInstallers$_c tl2$_ctl0','')

Notice how the links for both Edit and Update are identical?

Please help me figure why the update calls the edit and the cancel
just
posts...

Thanks in advance.

-Rick

PS.

Here is all the code, there are objects behind the scenes but these
are
tried and true.

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Job Tracking.aspx.v b"

Inherits="Patio .PCMS.WebClient .JobTracking"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>JobTrack ing</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<LINK href="/WebClient/Styles.css" type="text/css" rel="stylesheet ">
<script language="javas cript" src="/WebClient/global.js"></script>
</HEAD>
<body onload="onDocum entReady();">
<form id="Form1" method="post" runat="server">
<asp:datagrid id=dgContracts runat="server"
AutoGenerateCol umns="False"
DataSource="<%#

Contracts %>">
<Columns>
<asp:EditComman dColumn CancelText="Can cel" EditText="Edit"

UpdateText="Upa te"></asp:EditCommand Column>
<asp:TemplateCo lumn HeaderText="Job #">
<ItemTemplate >
<asp:Label runat="server" Text='<%#

DataBinder.Eval (Container, "DataItem.Job.J obNumber") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Pro duct">
<ItemTemplate >
<asp:Label runat="server" Text='<%#

DataBinder.Eval (Container, "DataItem.Produ ct.Description" ) %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Sta tus">
<ItemTemplate >
<asp:Label runat="server" Text='<%#

DataBinder.Eval (Container, "DataItem.Job.S tatus") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:ButtonColu mn Text="Select" ButtonType="Pus hButton"

ItemStyle-CssClass="submi t" CommandName="Se lect"></asp:ButtonColum n>
</Columns>
</asp:datagrid>
<br>
<table width="100%" border="0" cellpadding="1" cellspacing="0" >
<asp:repeater id=rptrJobActiv ities runat="server" DataSource="<%#

JobActivities(S electedContract Id)%>">
<ItemTemplate >
<tr style="FONT-WEIGHT: bold; COLOR: white; BACKGROUND-COLOR:
navy">
<td>
Description
</td>
<td>
Planned Start
</td>
<td>
Planned End
</td>
<td>
Actual End
</td>
<td>
Amount Due
</td>
<td>
Status
</td>
</tr>
<tr>
<td>
<%# DataBinder.Eval (Container,

"DataItem.Descr iption") %>
</td>
<td>
<%# DataBinder.Eval (Container,

"DataItem.PlanS tartDate.Date") .ToShortDateStr ing %>
</td>
<td>
<%# DataBinder.Eval (Container,

"DataItem.PlanE ndDate.Date").T oShortDateStrin g %>
</td>
<td>
<%# DataBinder.Eval (Container,

"DataItem.ActEn dDate.Date").To ShortDateString %>
</td>
<td>
<%# FormatCurrency( DataBinder.Eval (Container,

"DataItem.Amoun tDue"), 0) %>
</td>
<td>
<%# DataBinder.Eval (Container, "DataItem.Statu s") %>
</td>
</tr>
<tr>
<td colspan="3" align="center" valign="top">
Installers
<asp:DropDownLi st ID="ddlInstalle rWorkers"

DataSource='<%# InstallerWorker s()%>' DataTextField=" FullName"
DataValueField= "WorkerId" Runat="server" />
<asp:Button CssClass="submi t" ID="btnAddInsta ller"

Text="Add" OnClick="btnAdd Installer_Click " Runat="server" />
<asp:DataGrid ID="dgJobActivi tyInstallers"

AutoGenerateCol umns="False" Width="75%" Runat="server">
<HeaderStyle BackColor="Ligh tGrey" />
<Columns>
<asp:EditComman dColumn

ButtonType="Lin kButton" CancelText="Can cel" EditText="Edit"
UpdateText="Upd ate"/>
<asp:TemplateCo lumn>
<HeaderTemplate >
Installer
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.FullN ame") %>
</ItemTemplate>
<EditItemTempla te>
<%#

DataBinder.Eval (Container, "DataItem.FullN ame") %>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<HeaderTemplate >
Lead Installer?
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.LeadF lag") %>
</ItemTemplate>
<EditItemTempla te>
<asp:CheckBox

ID="chkLeadInst aller" Checked='<%# DataBinder.Eval (Container,
"DataItem.LeadF lag") %>' Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
</td>
<td colspan="3" align="center" valign="top">
Comments
<asp:Button CssClass="submi t"

ID="btnAddJobAc tivityComment" Text="Add" Runat="server" />
<asp:DataGrid AutoGenerateCol umns="False"

ID="dgJobActivi tyComments" width="75%" Runat="server">
<HeaderStyle BackColor="Ligh tGrey" />
<Columns>
<asp:TemplateCo lumn>
<HeaderTemplate >
Date
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.CommD ate") %>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<HeaderTemplate >
Comments
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.Comme nts") %>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox

ID="txtComments " Rows="4" Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>
</form>
</body>
</HTML>

Imports Patio.PCMS.Libr ary
Imports Patio.EAF

Public Class JobTracking
Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub
Protected WithEvents dgContracts As
System.Web.UI.W ebControls.Data Grid
Protected WithEvents rptrJobActiviti es As
System.Web.UI.W ebControls.Repe ater

'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Protected ReadOnly Property CustomerId() As Guid
Get
Return New Guid(Request.Qu eryString("Cust omerID"))
End Get
End Property

Protected ReadOnly Property LeadId() As Guid
Get
Return New Guid(Request.Qu eryString("Lead ID"))
End Get
End Property

Protected ReadOnly Property Customer() As Customer
Get
Return CType(Session(C ustomerId.ToStr ing), Customer)
End Get
End Property

Protected ReadOnly Property Lead() As Lead
Get
Return CType(Customer. Leads(LeadId), Lead)
End Get
End Property

Protected ReadOnly Property Contracts() As ContractCollect ion
Get
Return Lead.Contracts
End Get
End Property

Protected Property SelectedContrac tId() As Guid
Get
If Not Session("Select edContractId") Is Nothing Then
Return New Guid(CType(Sess ion("SelectedCo ntractId"), String))
End If
End Get
Set(ByVal Value As Guid)
Session("Select edContractId") = Value
End Set
End Property

Protected ReadOnly Property JobActivities() As JobActivityColl ection
Get
Try
Return Contracts(Selec tedContractId). Job.JobActiviti es
Catch ex As Exception
'
End Try

End Get
End Property

Protected ReadOnly Property JobActivities(B yVal ContractId As Guid)
As
JobActivityColl ection
Get
Try
Return Contracts(Contr actId).Job.JobA ctivities
Catch ex As Exception
'
End Try
End Get
End Property

Protected Property SelectedJobActi vityId() As Guid
Get
If Not CType(Session(" SelectedJobActi vityId"), String) Is Nothing
Then
Return New Guid(CType(Sess ion("SelectedJo bActivityId"), String))
End If
End Get
Set(ByVal Value As Guid)
Session("Select edJobActivityId ") = Value.ToString
End Set
End Property

Protected ReadOnly Property JobActivityInst allers() As
JobActivityInst allerCollection
Get
Return JobActivityInst allers(Selected JobActivityId)
End Get
End Property

Protected ReadOnly Property JobActivityInst allers(ByVal JobActivityId
As
Guid) As JobActivityInst allerCollection
Get
Return JobActivities() (JobActivityId) .Installers
End Get
End Property

Protected ReadOnly Property InstallerWorker s() As
ReadOnlyWorkerC ollection
Get
Return
ReadOnlyWorkerC ollection.GetRe adOnlyWorkerCol lection(Custome r.BusinessUnit. BusinessUnit,
True)
End Get
End Property

Protected ReadOnly Property Comments() As CommentCollecti on
Get
Return
CommentCollecti on.GetCommentCo llection(ReadOn lyCommentType.G etReadOnlyComme ntType("X"),
Me.SelectedJobA ctivityId, CommentCollecti on.UserFlagStat eEnum.All)
End Get
End Property

'Private Sub BindJobActivity InstallersGrid( ByVal dgInstallers As
DataGrid,
ByVal JobActivityId As Guid)
' dgInstallers.Da taSource = JobActivityInst allers(JobActiv ityId)
' dgInstallers.Da taBind()
'End Sub

'Private Sub BindJobActivity InstallersGrid( ByVal dgInstallers As
DataGrid)
' dgInstallers.Da taSource = JobActivityInst allers()
' dgInstallers.Da taBind()
'End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If CustomerId.Equa ls(Guid.Empty) OrElse LeadId.Equals(G uid.Empty)
Then
Response.Redire ct("LeadSearch. aspx", True)
End If

If Not IsPostBack Then
dgContracts.Dat aBind()
End If
End Sub

Private Sub dgContracts_Ite mCommand(ByVal source As Object, ByVal e
As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgContracts.Ite mCommand
If e.CommandName = "Select" Then
Dim itm As Contract = Contracts(e.Ite m.ItemIndex)

If Not itm Is Nothing Then
Session("Select edContractId") = itm.ContractId. ToString

JobActivities.S ortBySequence(S ortConstants.So rtAscending)

rptrJobActiviti es.DataSource = JobActivities
rptrJobActiviti es.DataBind()
End If
End If
End Sub

Private Sub rptrJobActiviti es_ItemCreated( ByVal sender As Object,
ByVal e
As System.Web.UI.W ebControls.Repe aterItemEventAr gs) Handles
rptrJobActiviti es.ItemCreated
Dim itm As JobActivity = JobActivities() (e.Item.ItemInd ex)

If Not itm Is Nothing Then
Dim dgInstallers As DataGrid =
CType(e.Item.Fi ndControl("dgJo bActivityInstal lers"), DataGrid)
Dim dbComments As DataGrid =
CType(e.Item.Fi ndControl("dgJo bActivityCommen ts"), DataGrid)

dgInstallers.Da taSource = JobActivityInst allers(itm.JobA ctivityId)
dgInstallers.Da taBind()

AddHandler dgInstallers.Ed itCommand, AddressOf
dgJobActivityIn stallers_EditCo mmand
AddHandler dgInstallers.Up dateCommand, AddressOf
dgJobActivityIn stallers_Update Command
AddHandler dgInstallers.Ca ncelCommand, AddressOf
dgJobActivityIn stallers_Cancel Command

dbComments.Data Source = Me.Comments
dbComments.Data Bind()
End If
End Sub

Protected Sub btnAddInstaller _Click(ByVal sender As Object, ByVal e
As
EventArgs)
Dim btn As Button = CType(sender, Button)
Dim ri As RepeaterItem = CType(btn.Paren t, RepeaterItem)
Dim ddl As DropDownList =
CType(ri.FindCo ntrol("ddlInsta llerWorkers"),
DropDownList)
Dim dgInstallers As DataGrid =
CType(ri.FindCo ntrol("dgJobAct ivityInstallers "), DataGrid)

SelectedJobActi vityId =
JobActivities(S electedContract Id)(ri.ItemInde x).JobActivityI d

Dim itm As ReadOnlyWorker = InstallerWorker s(ddl.SelectedI ndex)

If Not itm Is Nothing Then
If Not JobActivityInst allers Is Nothing Then
If Not JobActivityInst allers.Contains (itm.WorkerId) Then
JobActivityInst allers.Add(itm. WorkerId)
'dgInstallers.E ditItemIndex = -1

dgInstallers.Da taSource = JobActivityInst allers()
dgInstallers.Da taBind()

End If
End If
End If
End Sub

Protected Sub dgJobActivityIn stallers_EditCo mmand(ByVal source As
Object,
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.EditC ommand")
Dim dgInstallers As DataGrid = CType(source, DataGrid)

dgInstallers.Ed itItemIndex = e.Item.ItemInde x

'dgInstallers.D ataSource = JobActivityInst allers()
dgInstallers.Da taBind()

WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.EditC ommand " & dgInstallers.Ed itItemIndex)
End Sub

Protected Sub dgJobActivityIn stallers_Cancel Command(ByVal source As
Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.Cance lCommand")
Dim dgInstallers As DataGrid = CType(source, DataGrid)

dgInstallers.Ed itItemIndex = -1

'dgInstallers.D ataSource = JobActivityInst allers()
dgInstallers.Da taBind()
End Sub

Protected Sub dgJobActivityIn stallers_Update Command(ByVal source As
Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.Updat eCommand")
Dim dgInstallers As DataGrid = CType(source, DataGrid)

dgInstallers.Ed itItemIndex = -1

'dgInstallers.D ataSource = JobActivityInst allers()
dgInstallers.Da taBind()
End Sub

End Class
Nov 18 '05 #1
1 4334
Thanks for all the wonderful comments helping me get through this problem.

It is amazing to see so many helpful people gather in one place.

-Rick

"Rick" <ri************ *@hotmail.com> wrote in message
news:be******** *************** ***@posting.goo gle.com...
Hello all, I hope all is well with you.

I am having a seriously difficult time with this problem. Allow me to
set
up the problem.

I have a System.Web.UI.P age with the following controls (watch the
layout,
some have child controls):

1. DataGrid (dgContracts) - Lists current contracts.
1.1. ButtonColumn (CommandName SelectContract) - Selects a contract
to
use.
2. Repeater (rptrJobActivit ies) - Lists all Job Activities for a
Contract/Job when a user selects a contract from

dgContracts. Each RepeaterItem represents a single JobActivity.
2.1. DropDownList (ddlInstallers <asp:DropDownLi st
ID="ddlInstalle rWorkers" DataSource='<%#

InstallerWorker s()%>' DataTextField=" FullName"
DataValueField= "WorkerId"
Runat="server" />) Lists all available

Installers (people)
2.2. Button (btnAddInstalle r <asp:Button CssClass="submi t"
ID="btnAddInsta ller" Text="Add"

OnClick="btnAdd Installer_Click "

Runat="server" />) Adds the selected installer in ddlInstallers to the
JobActivityInst allers collection.
2.3. DataGrid (dgInstallers <asp:DataGrid
ID="dgJobActivi tyInstallers"
AutoGenerateCol umns="False"

Width="75%" Runat="server"> )

Displays the installers that are added to the job activity
(AddHandlers to
EditCommand, CancelCommand and

UpdateCommand in

rptrJobActiviti es_ItemCreated - NOTE: Originally I had these assigned
in
the <asp:DataGrid

OnEditCommand=" dgInstallers_Ed itCommand"
OnCancelCommand ="dgInstallers_ CancelCommand"

OnUpdateCommand ="dgInstallers_ UpdateCommand"/> until this problem came
up)
2.3.1. EditCommandColu mn (<asp:EditComma ndColumn
ButtonType="Lin kButton"
CancelText="Can cel"

EditText="Edit"

UpdateText="Upd ate"/>)
A user will load this page, dgContracts is DataBind only on Not
IsPostback,
select a contract from dgContracts, by

clicking the ButtonCol The page posts, dgContracts_Ite mCommand fires -
rpterJobActivit ies is DataBind, and

rptrJobActiviti es is populated with all the Job Activities associated
with
the selected contract. Everytime

rptrJobActiviti es_ItemCreated is fired dgInstallers is DataBind and
AddHandlers are assigned for each EditCommand,

CancelCommand and UpdateCommand (DataBind THEN AddHandlers)

Inside each Job Activity, repeater item, basic data is displayed and
dgInstallers is populated with Installers

working on this Job Activity.

The user is permitted to add new installers by selecting ddlInstallers
and
clicking btnAddInstaller . The page posts

and the newly added installer appears in dgInstallers.
btnAddInstaller _Click is fired and code adds to the

collection of installers.

Everything seems to work just fine up to this point.

Now, when you click the EditCommandColu mn 'Edit' Link it calls
dgInstallers_Ed itCommand, we set the edit index and

then DataBind. All well and good. When we click the EditCommandColu mn
"Cancel", the page just posts. No event is

fired. If we instead click the EditCommandColu mn "Update" link,
dgInstallers_Ed itCommand is fired once again.

When we hover the mouse over the Edit link, the actual link is:

javascript:__do PostBack('rptrJ obActivities$_c tl0$dgJobActivi tyInstallers$_c t
l2$_ctl0','')
When we hover the mouse over the Cancel link, the actual link is:

javascript:__do PostBack('rptrJ obActivities$_c tl0$dgJobActivi tyInstallers$_c t
l2$_ctl1','')
When we hover the mouse over the Update link, the actual link is:
javascript:__do PostBack('rptrJ obActivities$_c tl0$dgJobActivi tyInstallers$_c t
l2$_ctl0','')
Notice how the links for both Edit and Update are identical?

Please help me figure why the update calls the edit and the cancel
just
posts...

Thanks in advance.

-Rick

PS.

Here is all the code, there are objects behind the scenes but these
are
tried and true.

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Job Tracking.aspx.v b"

Inherits="Patio .PCMS.WebClient .JobTracking"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>JobTrack ing</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<LINK href="/WebClient/Styles.css" type="text/css" rel="stylesheet ">
<script language="javas cript" src="/WebClient/global.js"></script>
</HEAD>
<body onload="onDocum entReady();">
<form id="Form1" method="post" runat="server">
<asp:datagrid id=dgContracts runat="server"
AutoGenerateCol umns="False"
DataSource="<%#

Contracts %>">
<Columns>
<asp:EditComman dColumn CancelText="Can cel" EditText="Edit"

UpdateText="Upa te"></asp:EditCommand Column>
<asp:TemplateCo lumn HeaderText="Job #">
<ItemTemplate >
<asp:Label runat="server" Text='<%#

DataBinder.Eval (Container, "DataItem.Job.J obNumber") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Pro duct">
<ItemTemplate >
<asp:Label runat="server" Text='<%#

DataBinder.Eval (Container, "DataItem.Produ ct.Description" ) %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Sta tus">
<ItemTemplate >
<asp:Label runat="server" Text='<%#

DataBinder.Eval (Container, "DataItem.Job.S tatus") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:ButtonColu mn Text="Select" ButtonType="Pus hButton"

ItemStyle-CssClass="submi t" CommandName="Se lect"></asp:ButtonColum n>
</Columns>
</asp:datagrid>
<br>
<table width="100%" border="0" cellpadding="1" cellspacing="0" >
<asp:repeater id=rptrJobActiv ities runat="server" DataSource="<%#

JobActivities(S electedContract Id)%>">
<ItemTemplate >
<tr style="FONT-WEIGHT: bold; COLOR: white; BACKGROUND-COLOR:
navy">
<td>
Description
</td>
<td>
Planned Start
</td>
<td>
Planned End
</td>
<td>
Actual End
</td>
<td>
Amount Due
</td>
<td>
Status
</td>
</tr>
<tr>
<td>
<%# DataBinder.Eval (Container,

"DataItem.Descr iption") %>
</td>
<td>
<%# DataBinder.Eval (Container,

"DataItem.PlanS tartDate.Date") .ToShortDateStr ing %>
</td>
<td>
<%# DataBinder.Eval (Container,

"DataItem.PlanE ndDate.Date").T oShortDateStrin g %>
</td>
<td>
<%# DataBinder.Eval (Container,

"DataItem.ActEn dDate.Date").To ShortDateString %>
</td>
<td>
<%# FormatCurrency( DataBinder.Eval (Container,

"DataItem.Amoun tDue"), 0) %>
</td>
<td>
<%# DataBinder.Eval (Container, "DataItem.Statu s") %>
</td>
</tr>
<tr>
<td colspan="3" align="center" valign="top">
Installers
<asp:DropDownLi st ID="ddlInstalle rWorkers"

DataSource='<%# InstallerWorker s()%>' DataTextField=" FullName"
DataValueField= "WorkerId" Runat="server" />
<asp:Button CssClass="submi t" ID="btnAddInsta ller"

Text="Add" OnClick="btnAdd Installer_Click " Runat="server" />
<asp:DataGrid ID="dgJobActivi tyInstallers"

AutoGenerateCol umns="False" Width="75%" Runat="server">
<HeaderStyle BackColor="Ligh tGrey" />
<Columns>
<asp:EditComman dColumn

ButtonType="Lin kButton" CancelText="Can cel" EditText="Edit"
UpdateText="Upd ate"/>
<asp:TemplateCo lumn>
<HeaderTemplate >
Installer
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.FullN ame") %>
</ItemTemplate>
<EditItemTempla te>
<%#

DataBinder.Eval (Container, "DataItem.FullN ame") %>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<HeaderTemplate >
Lead Installer?
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.LeadF lag") %>
</ItemTemplate>
<EditItemTempla te>
<asp:CheckBox

ID="chkLeadInst aller" Checked='<%# DataBinder.Eval (Container,
"DataItem.LeadF lag") %>' Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
</td>
<td colspan="3" align="center" valign="top">
Comments
<asp:Button CssClass="submi t"

ID="btnAddJobAc tivityComment" Text="Add" Runat="server" />
<asp:DataGrid AutoGenerateCol umns="False"

ID="dgJobActivi tyComments" width="75%" Runat="server">
<HeaderStyle BackColor="Ligh tGrey" />
<Columns>
<asp:TemplateCo lumn>
<HeaderTemplate >
Date
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.CommD ate") %>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<HeaderTemplate >
Comments
</HeaderTemplate>
<ItemTemplate >
<%#

DataBinder.Eval (Container, "DataItem.Comme nts") %>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox

ID="txtComments " Rows="4" Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</ItemTemplate>
</asp:repeater>
</table>
</form>
</body>
</HTML>

Imports Patio.PCMS.Libr ary
Imports Patio.EAF

Public Class JobTracking
Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub
Protected WithEvents dgContracts As
System.Web.UI.W ebControls.Data Grid
Protected WithEvents rptrJobActiviti es As
System.Web.UI.W ebControls.Repe ater

'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Protected ReadOnly Property CustomerId() As Guid
Get
Return New Guid(Request.Qu eryString("Cust omerID"))
End Get
End Property

Protected ReadOnly Property LeadId() As Guid
Get
Return New Guid(Request.Qu eryString("Lead ID"))
End Get
End Property

Protected ReadOnly Property Customer() As Customer
Get
Return CType(Session(C ustomerId.ToStr ing), Customer)
End Get
End Property

Protected ReadOnly Property Lead() As Lead
Get
Return CType(Customer. Leads(LeadId), Lead)
End Get
End Property

Protected ReadOnly Property Contracts() As ContractCollect ion
Get
Return Lead.Contracts
End Get
End Property

Protected Property SelectedContrac tId() As Guid
Get
If Not Session("Select edContractId") Is Nothing Then
Return New Guid(CType(Sess ion("SelectedCo ntractId"), String))
End If
End Get
Set(ByVal Value As Guid)
Session("Select edContractId") = Value
End Set
End Property

Protected ReadOnly Property JobActivities() As JobActivityColl ection
Get
Try
Return Contracts(Selec tedContractId). Job.JobActiviti es
Catch ex As Exception
'
End Try

End Get
End Property

Protected ReadOnly Property JobActivities(B yVal ContractId As Guid)
As
JobActivityColl ection
Get
Try
Return Contracts(Contr actId).Job.JobA ctivities
Catch ex As Exception
'
End Try
End Get
End Property

Protected Property SelectedJobActi vityId() As Guid
Get
If Not CType(Session(" SelectedJobActi vityId"), String) Is Nothing
Then
Return New Guid(CType(Sess ion("SelectedJo bActivityId"), String))
End If
End Get
Set(ByVal Value As Guid)
Session("Select edJobActivityId ") = Value.ToString
End Set
End Property

Protected ReadOnly Property JobActivityInst allers() As
JobActivityInst allerCollection
Get
Return JobActivityInst allers(Selected JobActivityId)
End Get
End Property

Protected ReadOnly Property JobActivityInst allers(ByVal JobActivityId
As
Guid) As JobActivityInst allerCollection
Get
Return JobActivities() (JobActivityId) .Installers
End Get
End Property

Protected ReadOnly Property InstallerWorker s() As
ReadOnlyWorkerC ollection
Get
Return
ReadOnlyWorkerC ollection.GetRe adOnlyWorkerCol lection(Custome r.BusinessUnit. B
usinessUnit, True)
End Get
End Property

Protected ReadOnly Property Comments() As CommentCollecti on
Get
Return
CommentCollecti on.GetCommentCo llection(ReadOn lyCommentType.G etReadOnlyComme n
tType("X"), Me.SelectedJobA ctivityId, CommentCollecti on.UserFlagStat eEnum.All)
End Get
End Property

'Private Sub BindJobActivity InstallersGrid( ByVal dgInstallers As
DataGrid,
ByVal JobActivityId As Guid)
' dgInstallers.Da taSource = JobActivityInst allers(JobActiv ityId)
' dgInstallers.Da taBind()
'End Sub

'Private Sub BindJobActivity InstallersGrid( ByVal dgInstallers As
DataGrid)
' dgInstallers.Da taSource = JobActivityInst allers()
' dgInstallers.Da taBind()
'End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If CustomerId.Equa ls(Guid.Empty) OrElse LeadId.Equals(G uid.Empty)
Then
Response.Redire ct("LeadSearch. aspx", True)
End If

If Not IsPostBack Then
dgContracts.Dat aBind()
End If
End Sub

Private Sub dgContracts_Ite mCommand(ByVal source As Object, ByVal e
As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgContracts.Ite mCommand
If e.CommandName = "Select" Then
Dim itm As Contract = Contracts(e.Ite m.ItemIndex)

If Not itm Is Nothing Then
Session("Select edContractId") = itm.ContractId. ToString

JobActivities.S ortBySequence(S ortConstants.So rtAscending)

rptrJobActiviti es.DataSource = JobActivities
rptrJobActiviti es.DataBind()
End If
End If
End Sub

Private Sub rptrJobActiviti es_ItemCreated( ByVal sender As Object,
ByVal e
As System.Web.UI.W ebControls.Repe aterItemEventAr gs) Handles
rptrJobActiviti es.ItemCreated
Dim itm As JobActivity = JobActivities() (e.Item.ItemInd ex)

If Not itm Is Nothing Then
Dim dgInstallers As DataGrid =
CType(e.Item.Fi ndControl("dgJo bActivityInstal lers"), DataGrid)
Dim dbComments As DataGrid =
CType(e.Item.Fi ndControl("dgJo bActivityCommen ts"), DataGrid)

dgInstallers.Da taSource = JobActivityInst allers(itm.JobA ctivityId)
dgInstallers.Da taBind()

AddHandler dgInstallers.Ed itCommand, AddressOf
dgJobActivityIn stallers_EditCo mmand
AddHandler dgInstallers.Up dateCommand, AddressOf
dgJobActivityIn stallers_Update Command
AddHandler dgInstallers.Ca ncelCommand, AddressOf
dgJobActivityIn stallers_Cancel Command

dbComments.Data Source = Me.Comments
dbComments.Data Bind()
End If
End Sub

Protected Sub btnAddInstaller _Click(ByVal sender As Object, ByVal e
As
EventArgs)
Dim btn As Button = CType(sender, Button)
Dim ri As RepeaterItem = CType(btn.Paren t, RepeaterItem)
Dim ddl As DropDownList =
CType(ri.FindCo ntrol("ddlInsta llerWorkers"),
DropDownList)
Dim dgInstallers As DataGrid =
CType(ri.FindCo ntrol("dgJobAct ivityInstallers "), DataGrid)

SelectedJobActi vityId =
JobActivities(S electedContract Id)(ri.ItemInde x).JobActivityI d

Dim itm As ReadOnlyWorker = InstallerWorker s(ddl.SelectedI ndex)

If Not itm Is Nothing Then
If Not JobActivityInst allers Is Nothing Then
If Not JobActivityInst allers.Contains (itm.WorkerId) Then
JobActivityInst allers.Add(itm. WorkerId)
'dgInstallers.E ditItemIndex = -1

dgInstallers.Da taSource = JobActivityInst allers()
dgInstallers.Da taBind()

End If
End If
End If
End Sub

Protected Sub dgJobActivityIn stallers_EditCo mmand(ByVal source As
Object,
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.EditC ommand")
Dim dgInstallers As DataGrid = CType(source, DataGrid)

dgInstallers.Ed itItemIndex = e.Item.ItemInde x

'dgInstallers.D ataSource = JobActivityInst allers()
dgInstallers.Da taBind()

WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.EditC ommand " & dgInstallers.Ed itItemIndex)
End Sub

Protected Sub dgJobActivityIn stallers_Cancel Command(ByVal source As
Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.Cance lCommand")
Dim dgInstallers As DataGrid = CType(source, DataGrid)

dgInstallers.Ed itItemIndex = -1

'dgInstallers.D ataSource = JobActivityInst allers()
dgInstallers.Da taBind()
End Sub

Protected Sub dgJobActivityIn stallers_Update Command(ByVal source As
Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
WriteDebugMessa ge(HttpContext. Current, Me,
"dgJobActivityI nstallers.Updat eCommand")
Dim dgInstallers As DataGrid = CType(source, DataGrid)

dgInstallers.Ed itItemIndex = -1

'dgInstallers.D ataSource = JobActivityInst allers()
dgInstallers.Da taBind()
End Sub

End Class

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12236
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
0
2261
by: Chad Folden | last post by:
I can't figure out how to use the EditCommand for the nested datagrid .. HELP PLEASE ;-) It works perfectly for the parent datagrid, but will not display, even though the EditCommand event is firing for the child datagrid. I have set up a test page for myself to see if I can get this to work ..any help is appreciated! Thanks in advance (This is my complete page and code behind) <asp:DataGrid ID="_dgProj" AllowPaging=False
8
1712
by: Brent Burkart | last post by:
My datagrid OnCancelCommand event is not firing. HTML OnCancelCommand="AdminGrid_Cancel" 'Code Behind Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) AdminGrid.EditItemIndex = -1 BindData()
0
693
by: Richard Ryerson | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls): 1. DataGrid (dgContracts) - Lists current contracts. 1.1. ButtonColumn (CommandName SelectContract) - Selects a contract to
0
473
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass = "SectionTableLines"; dgG.DataKeyField = "PlanWorkOrderID";
2
1580
by: andrew.roberts | last post by:
This is my second post now on this subject has I seem to be getting no where and the problem is really starting to bug me now. I can get a datagrid into an editable state but then neither the Update or Cancel events seem to be firing and I am at a lost to explan why. My code is below, if any one can tell me what I am doing wrong then that would be excellent! using System; using System.Collections; using System.ComponentModel;
1
5160
by: kevin | last post by:
Hi, I'm working with VS 2005 and Framework 2.0 I have a datagrid with a link and the selectedindexchanged will not fire. The page posts back but does nothing. Protected Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged Label2.Text = "what the H"
9
2724
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
0
1535
by: arlie_maija | last post by:
Hey - I'm writing a control that contains a DataGrid, and I'm unable to get the update event to fire. When I click the update link, the edit event fires. heres the details... my control overrides CreateChildControls and dynamically creates the DataGrid, creates an EditCommandColumn which it adds to the
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.