kbailey23342
asked on
Datagrid Losing Viewstate on Postback
Experts: I'm in need of some help on a datagrid problem I've been chasing for two days now. I have a datagrid setup with template columns including two link buttons (one called Approve and one called Reject). When the datagrid binds the first time, the itemcommand event fires just fine for either button. When the datagrid binds the second time, the itemcommand event DOES NOT fire for either button (nor does any other datagrid event). When the datagrid binds the third time, the itemcommand event fires just fine, so on and so on.
I am binding to a rather large class with several sub-classes inside. Again, the databind Appears to work fine for each trip through. I have viewstate set to true for the datagrid. I have autoevebtwireup set to false for the page. I have pagination turned off.
Has anyone else had this similar problem?
I'm running Visual Studio .Net 2003, Windows XP Pro op system, connecting to a SQL Server backend. This is my first experience with databinding problems.
Thanks in advance,
kbailey23342
I am binding to a rather large class with several sub-classes inside. Again, the databind Appears to work fine for each trip through. I have viewstate set to true for the datagrid. I have autoevebtwireup set to false for the page. I have pagination turned off.
Has anyone else had this similar problem?
I'm running Visual Studio .Net 2003, Windows XP Pro op system, connecting to a SQL Server backend. This is my first experience with databinding problems.
Thanks in advance,
kbailey23342
ASKER
No, I'm not dynamically adding controls to the grid. All the controls are added via the datagrid creation tool. The only controls that exist are the two link buttons mentioned above. Outside of that, there are 8 other fields that deplay data from the class I'm connecting to.
- Kbailey23342
- Kbailey23342
Could you post the source/code?
ASKER
Can't post until Monday, but will do then...
may be also because you are not doing something like this in page_load
If not page.ispostback = true
BindGrid()
End If
If not page.ispostback = true
BindGrid()
End If
ASKER
Here's the entier page scenario: There are two date-picker boxes (beginning date, ending date), and one Refresh button. The refresh button fires a loaddata method which then fires a binddata method. The loaddata method loads data into an HTTPContext session variable. The binddata method retrieves the HTTPContext session variable and binds the grid to that data. The datagrid contains 10 total columns (including the two link buttons mentioned above).
All controls have enable viewstate set to true. The date-picker boxes are richdatepicker controls.
- kbailey23342
All controls have enable viewstate set to true. The date-picker boxes are richdatepicker controls.
- kbailey23342
Post the code when you get a chance, it's probably something very simple.
ASKER
I'll post the HTML and Code-Behind on Monday. I have looked over the code and I know it's something simple I've missed.
ASKER
I am posting the HTML and Code-Behind logic. Code-Behind is written in VB.Net.
<%@ Register TagPrefix="cc1" Namespace="RicherComponent s.DatePick erControl" Assembly="RichDatePicker" %>
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="PTRefundProces sing.ascx. vb" Inherits="ACS.PTRefundProc essingScre en" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<center><asp:datagrid id="ValSum" DESIGNTIMEDRAGDROP="2" runat="server" CssClass="cssDataGrid" width="75%"
AutoGenerateColumns="False " Visible="False" CellPadding="5" CellSpacing="1" GridLines="None" EnableViewState="false">
<AlternatingItemStyle CssClass="cssDataGridAlter natingItem "></Altern atingItemS tyle>
<ItemStyle CssClass="cssDataGridItem" ></ItemSty le>
<Columns>
<asp:TemplateColumn HeaderText="Error Message(s)" HeaderStyle-Font-Bold="tru e">
<HeaderStyle Width="1%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle Wrap="True" Font-Bold="True"></ItemSty le>
<ItemTemplate>
<asp:Label ID="msg" Runat="server">
<%# "• " + Container.DataItem %>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></center>
<% if ValSum.Items.Count > 0 Then
Response.Write("<br> <br>")
End If
%>
<table id="table1" cellSpacing="0" cellPadding="10" width="100%" border="0">
<tr>
<td class="lightBgColor" vAlign="top" width="100%"><span class="BoldHeader"><asp:la bel id="lblStep" runat="server">Enter a begin and end date to located any refund or 3 day cancel requests. A listing of PT agreements with requests will be displayed. By pressing the Approve or Reject link next to the corresponding agreement the request will be updated.</asp:label></span >
</td>
</tr>
</table>
<br>
<br>
<table class="cssDataGridItem" id="table2" cellSpacing="0" cellPadding="4" width="100%"
border="0">
<tr class="cssDataGridItem">
<td align="right" width="30%">Begin Date (MM/DD/YYYY):</td>
<td align="left" width="70%"><asp:textbox id="txtBeginDate" tabIndex="1" runat="server" Width="90px" MaxLength="10"></asp:textb ox></td>
</tr>
<tr class="cssDataGridItem" align="right">
<td align="right" width="30%">End Date (MM/DD/YYYY):</td>
<td align="left" width="70%"><asp:textbox id="txtEndDate" tabIndex="2" runat="server" Width="90px" MaxLength="10"></asp:textb ox></td>
</tr>
<tr class="cssDataGridItem">
<td width="30%"></td>
<td align="left" width="70%"><asp:button id="btnRefresh" tabIndex="3" runat="server" CssClass="buttonOn" Text="Refresh"></asp:butto n></td>
</tr>
</table>
<br>
<br>
<table id="table3" cellSpacing="0" cellPadding="4" width="100%" border="0">
<tr>
<td><asp:datagrid id="dgSearchResults" runat="server" CssClass="cssDataGrid" AutoGenerateColumns="False " CellPadding="5" CellSpacing="1" GridLines="None" Width="100%" PageSize="25" AllowPaging="True" DataKeyField="ID">
<FooterStyle HorizontalAlign="Center" CssClass="cssDataGridItem" ></FooterS tyle>
<EditItemStyle CssClass="cssDataGridItem" ></EditIte mStyle>
<AlternatingItemStyle CssClass="cssDataGridAlter natingItem "></Altern atingItemS tyle>
<ItemStyle CssClass="cssDataGridItem" ></ItemSty le>
<Columns>
<asp:TemplateColumn HeaderText="PT ID">
<HeaderStyle HorizontalAlign="Center" Width="5%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "Id") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Customer Name">
<HeaderStyle HorizontalAlign="Center" Width="12%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Left"></I temStyle>
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "PrimaryMember.FullName") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Status">
<HeaderStyle HorizontalAlign="Center" Width="6%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "Status.Description") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Requested By">
<HeaderStyle HorizontalAlign="Center" Width="12%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Left"></I temStyle>
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "StatusChangeRequestBy.Ful lname") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Request Date">
<HeaderStyle HorizontalAlign="Center" Width="8%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "StatusDate", "{0:MM/dd/yyyy}") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Reason">
<HeaderStyle HorizontalAlign="Center" Width="6%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "RefundReason.Description" ) %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Club">
<HeaderStyle HorizontalAlign="Center" Width="5%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "Club.Abbreviation") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Trainer Name">
<HeaderStyle HorizontalAlign="Center" Width="12%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Left"></I temStyle>
<ItemTemplate>
<%# databinder.eval(Container. Dataitem, "Trainer.Fullname") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle Width="6%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<asp:LinkButton id="lbtnApprove" runat="server" Text="Approve" CommandName="Approve" CausesValidation="false">< /asp:LinkB utton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle Width="6%" CssClass="cssDataGridHeade r"></Heade rStyle>
<ItemStyle HorizontalAlign="Center">< /ItemStyle >
<ItemTemplate>
<asp:LinkButton id="lbtnReject" runat="server" Text="Reject" CommandName="Reject" CausesValidation="false">< /asp:LinkB utton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="Next >" PrevPageText="< Previous" HorizontalAlign="Center" ForeColor="Black" Position="TopAndBottom" BackColor="#FEBF01" Mode="NumericPages"></Page rStyle>
</asp:datagrid>
</td>
</tr>
</table>
<%@ Register TagPrefix="cc1" Namespace="RicherComponent
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="PTRefundProces
<center><asp:datagrid id="ValSum" DESIGNTIMEDRAGDROP="2" runat="server" CssClass="cssDataGrid" width="75%"
AutoGenerateColumns="False
<AlternatingItemStyle CssClass="cssDataGridAlter
<ItemStyle CssClass="cssDataGridItem"
<Columns>
<asp:TemplateColumn HeaderText="Error Message(s)" HeaderStyle-Font-Bold="tru
<HeaderStyle Width="1%" CssClass="cssDataGridHeade
<ItemStyle Wrap="True" Font-Bold="True"></ItemSty
<ItemTemplate>
<asp:Label ID="msg" Runat="server">
<%# "• " + Container.DataItem %>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></center>
<% if ValSum.Items.Count > 0 Then
Response.Write("<br>
End If
%>
<table id="table1" cellSpacing="0" cellPadding="10" width="100%" border="0">
<tr>
<td class="lightBgColor" vAlign="top" width="100%"><span class="BoldHeader"><asp:la
</td>
</tr>
</table>
<br>
<br>
<table class="cssDataGridItem" id="table2" cellSpacing="0" cellPadding="4" width="100%"
border="0">
<tr class="cssDataGridItem">
<td align="right" width="30%">Begin Date (MM/DD/YYYY):</td>
<td align="left" width="70%"><asp:textbox id="txtBeginDate" tabIndex="1" runat="server" Width="90px" MaxLength="10"></asp:textb
</tr>
<tr class="cssDataGridItem" align="right">
<td align="right" width="30%">End Date (MM/DD/YYYY):</td>
<td align="left" width="70%"><asp:textbox id="txtEndDate" tabIndex="2" runat="server" Width="90px" MaxLength="10"></asp:textb
</tr>
<tr class="cssDataGridItem">
<td width="30%"></td>
<td align="left" width="70%"><asp:button id="btnRefresh" tabIndex="3" runat="server" CssClass="buttonOn" Text="Refresh"></asp:butto
</tr>
</table>
<br>
<br>
<table id="table3" cellSpacing="0" cellPadding="4" width="100%" border="0">
<tr>
<td><asp:datagrid id="dgSearchResults" runat="server" CssClass="cssDataGrid" AutoGenerateColumns="False
<FooterStyle HorizontalAlign="Center" CssClass="cssDataGridItem"
<EditItemStyle CssClass="cssDataGridItem"
<AlternatingItemStyle CssClass="cssDataGridAlter
<ItemStyle CssClass="cssDataGridItem"
<Columns>
<asp:TemplateColumn HeaderText="PT ID">
<HeaderStyle HorizontalAlign="Center" Width="5%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Customer Name">
<HeaderStyle HorizontalAlign="Center" Width="12%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Left"></I
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Status">
<HeaderStyle HorizontalAlign="Center" Width="6%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Requested By">
<HeaderStyle HorizontalAlign="Center" Width="12%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Left"></I
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Request Date">
<HeaderStyle HorizontalAlign="Center" Width="8%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Reason">
<HeaderStyle HorizontalAlign="Center" Width="6%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Club">
<HeaderStyle HorizontalAlign="Center" Width="5%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Trainer Name">
<HeaderStyle HorizontalAlign="Center" Width="12%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Left"></I
<ItemTemplate>
<%# databinder.eval(Container.
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle Width="6%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<asp:LinkButton id="lbtnApprove" runat="server" Text="Approve" CommandName="Approve" CausesValidation="false"><
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle Width="6%" CssClass="cssDataGridHeade
<ItemStyle HorizontalAlign="Center"><
<ItemTemplate>
<asp:LinkButton id="lbtnReject" runat="server" Text="Reject" CommandName="Reject" CausesValidation="false"><
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="Next >" PrevPageText="< Previous" HorizontalAlign="Center" ForeColor="Black" Position="TopAndBottom" BackColor="#FEBF01" Mode="NumericPages"></Page
</asp:datagrid>
</td>
</tr>
</table>
ASKER
Here is the code-behind page:
The following imports are a classes associated with the build of the project. We're using true OO methodologies on this project:
Imports Lifestyle.Accessor.PT
Imports Lifestyle.Structures.PT
Imports LifeStyle.Entity.pt
Imports LifeStyle.Accessor
Imports Lifestyle.structures
Imports LifeStyle.Entity
Imports LifeStyle.Entity.PT.LookUp s
Imports Lifestyle.Enumeration
Imports Lifestyle.Entity.PT.agreem ent
Imports Microsoft.ApplicationBlock s.Exceptio nManagemen t
Public Class PTRefundProcessingScreen
Inherits SinglePageAppControl
Dim oRepresentative As Representative = GetRepresentation(HttpCont ext.Curren t)
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
End Sub
Protected WithEvents ValSum As System.Web.UI.WebControls. DataGrid
Protected WithEvents lblStep As System.Web.UI.WebControls. Label
Protected WithEvents btnRefresh As System.Web.UI.WebControls. Button
Protected WithEvents dgSearchResults As System.Web.UI.WebControls. DataGrid
Protected WithEvents txtBeginDate As System.Web.UI.WebControls. TextBox
Protected WithEvents txtEndDate As System.Web.UI.WebControls. TextBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara tion As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
SetSummary(ValSum)
If Not IsPostBack Then
txtBeginDate.Text = Date.Now.ToShortDateString
txtEndDate.Text = Date.Now.ToShortDateString
LoadData(Date.Now.Date, Date.Now.Date)
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x)
End Try
End Sub
Private Sub dgSearchResults_ItemCreate d(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. DataGridIt emEventArg s) Handles dgSearchResults.ItemCreate d
Try
SetSummary(ValSum)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingIt em
Dim myApproveButton As LinkButton
myApproveButton = e.Item.FindControl("lbtnAp prove")
myApproveButton.Attributes .Add("oncl ick", "return confirm('Are you sure you want to Approve this item?');")
Dim myRejectButton As LinkButton
myRejectButton = e.Item.FindControl("lbtnRe ject")
myRejectButton.Attributes. Add("oncli ck", "return confirm('Are you sure you want to Reject this item?');")
End Select
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
Private Sub dgSearchResults_ItemDataBo und(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. DataGridIt emEventArg s) Handles dgSearchResults.ItemDataBo und
Dim CurrentPTAgreement As PTAgreement
Dim RefundCollection As PTRefundCollection
Dim id As Integer
Dim lnkBtn As LinkButton
Try
SetSummary(ValSum)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingIt em Then
RefundCollection = GetListing(HttpContext.Cur rent)
id = dgSearchResults.DataKeys.I tem(e.Item .ItemIndex )
CurrentPTAgreement = RefundCollection.ViewItem( id)
' if the current status is refunded or three day cancelled, then don't display linkbuttons
If (CurrentPTAgreement.Status .Id = PTStatus.Refunded.Id) Then
' turn off visibility to the approved link button
lnkBtn = e.Item.FindControl("lbtnAp prove")
lnkBtn.Visible = False
' turn off visibility to the rejected link button
lnkBtn = e.Item.FindControl("lbtnRe ject")
lnkBtn.Visible = False
End If
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
Private Sub dgSearchResults_ItemComman d(ByVal source As Object, ByVal e As System.Web.UI.WebControls. DataGridCo mmandEvent Args) Handles dgSearchResults.ItemComman d
Dim CurrentPTAgreement As PTAgreement
Dim RefundCollection As PTRefundCollection
Dim Approve As Boolean
Try
SetSummary(ValSum)
If e.Item.ItemIndex >= 0 Then
RefundCollection = GetListing(HttpContext.Cur rent)
ID = dgSearchResults.DataKeys.I tem(e.Item .ItemIndex )
CurrentPTAgreement = RefundCollection.ViewItem( ID)
If e.CommandName = "Approve" Then
Approve = True
End If
If e.CommandName = "Reject" Then
Approve = False
End If
If CurrentPTAgreement.Status. Id = PTStatus.RefundRequest.Id Then
CurrentPTAgreement.RefundP rocess(App rove, RefundCollection)
Me.SetListing(HttpContext. Current, RefundCollection)
BindGrid()
End If
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
Try
SetSummary(ValSum)
Dim tmpBeginDate As Date
Dim tmpEndDate As Date
If Trim(txtBeginDate.Text) = "" Then
AddErrorMessage("Please Enter a beginning date!")
txtBeginDate.Text = Date.Now.ToShortDateString
End If
If Trim(txtEndDate.Text) = "" Then
AddErrorMessage("Please enter an ending date!")
txtEndDate.Text = Date.Now.ToShortDateString
End If
Try
tmpBeginDate = CDate(txtBeginDate.Text).T oShortDate String
tmpEndDate = CDate(txtEndDate.Text).ToS hortDateSt ring
If (tmpBeginDate > tmpEndDate) Then
AddErrorMessage("The beginning date must be <= the ending date.")
End If
Catch ex As Exception
AddErrorMessage("The beginning date or ending date is invalid.")
End Try
If Me.IsValid Then
LoadData(tmpBeginDate, tmpEndDate)
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
Private Sub LoadData(ByVal in_BeginDate As Date, ByVal in_EndDate As Date)
Try
SetSummary(ValSum)
Dim RefundCollection As PTRefundCollection
RefundCollection = PTAgreement.RefundsAvailab le(in_Begi nDate, in_EndDate, oRepresentative)
Me.SetListing(HttpContext. Current, RefundCollection)
BindGrid()
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
Public Sub BindGrid()
Try
SetSummary(ValSum)
Dim RefundCollection As PTRefundCollection
Dim al As ArrayList
RefundCollection = Me.GetListing(HttpContext. Current)
al = RefundCollection.GetList
Me.dgSearchResults.DataSou rce = al
Me.dgSearchResults.DataBin d()
Catch ex As PTBusinessException
AddErrorMessage(ex.Message )
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
Public Shadows Function GetListing(ByVal oHTTPContext As System.Web.HttpContext) As LifeStyle.Entity.PT.Agreem ent.PTRefu ndCollecti on
Try
SetSummary(ValSum)
Return CType(oHTTPContext.Session ("sesPTCol lection"), LifeStyle.Entity.PT.agreem ent.PTRefu ndCollecti on)
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Function
Public Shadows Sub SetListing(ByVal oHTTPContext As System.Web.HttpContext, ByVal al As LifeStyle.Entity.PT.Agreem ent.PTRefu ndCollecti on)
Try
SetSummary(ValSum)
oHTTPContext.Session("sesP TCollectio n") = al
Catch ex As Exception
AddErrorMessage(ex.Message )
ExceptionManager.Publish(e x, True)
End Try
End Sub
End Class
The following imports are a classes associated with the build of the project. We're using true OO methodologies on this project:
Imports Lifestyle.Accessor.PT
Imports Lifestyle.Structures.PT
Imports LifeStyle.Entity.pt
Imports LifeStyle.Accessor
Imports Lifestyle.structures
Imports LifeStyle.Entity
Imports LifeStyle.Entity.PT.LookUp
Imports Lifestyle.Enumeration
Imports Lifestyle.Entity.PT.agreem
Imports Microsoft.ApplicationBlock
Public Class PTRefundProcessingScreen
Inherits SinglePageAppControl
Dim oRepresentative As Representative = GetRepresentation(HttpCont
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
End Sub
Protected WithEvents ValSum As System.Web.UI.WebControls.
Protected WithEvents lblStep As System.Web.UI.WebControls.
Protected WithEvents btnRefresh As System.Web.UI.WebControls.
Protected WithEvents dgSearchResults As System.Web.UI.WebControls.
Protected WithEvents txtBeginDate As System.Web.UI.WebControls.
Protected WithEvents txtEndDate As System.Web.UI.WebControls.
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
SetSummary(ValSum)
If Not IsPostBack Then
txtBeginDate.Text = Date.Now.ToShortDateString
txtEndDate.Text = Date.Now.ToShortDateString
LoadData(Date.Now.Date, Date.Now.Date)
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Private Sub dgSearchResults_ItemCreate
Try
SetSummary(ValSum)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingIt
Dim myApproveButton As LinkButton
myApproveButton = e.Item.FindControl("lbtnAp
myApproveButton.Attributes
Dim myRejectButton As LinkButton
myRejectButton = e.Item.FindControl("lbtnRe
myRejectButton.Attributes.
End Select
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Private Sub dgSearchResults_ItemDataBo
Dim CurrentPTAgreement As PTAgreement
Dim RefundCollection As PTRefundCollection
Dim id As Integer
Dim lnkBtn As LinkButton
Try
SetSummary(ValSum)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingIt
RefundCollection = GetListing(HttpContext.Cur
id = dgSearchResults.DataKeys.I
CurrentPTAgreement = RefundCollection.ViewItem(
' if the current status is refunded or three day cancelled, then don't display linkbuttons
If (CurrentPTAgreement.Status
' turn off visibility to the approved link button
lnkBtn = e.Item.FindControl("lbtnAp
lnkBtn.Visible = False
' turn off visibility to the rejected link button
lnkBtn = e.Item.FindControl("lbtnRe
lnkBtn.Visible = False
End If
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Private Sub dgSearchResults_ItemComman
Dim CurrentPTAgreement As PTAgreement
Dim RefundCollection As PTRefundCollection
Dim Approve As Boolean
Try
SetSummary(ValSum)
If e.Item.ItemIndex >= 0 Then
RefundCollection = GetListing(HttpContext.Cur
ID = dgSearchResults.DataKeys.I
CurrentPTAgreement = RefundCollection.ViewItem(
If e.CommandName = "Approve" Then
Approve = True
End If
If e.CommandName = "Reject" Then
Approve = False
End If
If CurrentPTAgreement.Status.
CurrentPTAgreement.RefundP
Me.SetListing(HttpContext.
BindGrid()
End If
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
Try
SetSummary(ValSum)
Dim tmpBeginDate As Date
Dim tmpEndDate As Date
If Trim(txtBeginDate.Text) = "" Then
AddErrorMessage("Please Enter a beginning date!")
txtBeginDate.Text = Date.Now.ToShortDateString
End If
If Trim(txtEndDate.Text) = "" Then
AddErrorMessage("Please enter an ending date!")
txtEndDate.Text = Date.Now.ToShortDateString
End If
Try
tmpBeginDate = CDate(txtBeginDate.Text).T
tmpEndDate = CDate(txtEndDate.Text).ToS
If (tmpBeginDate > tmpEndDate) Then
AddErrorMessage("The beginning date must be <= the ending date.")
End If
Catch ex As Exception
AddErrorMessage("The beginning date or ending date is invalid.")
End Try
If Me.IsValid Then
LoadData(tmpBeginDate, tmpEndDate)
End If
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Private Sub LoadData(ByVal in_BeginDate As Date, ByVal in_EndDate As Date)
Try
SetSummary(ValSum)
Dim RefundCollection As PTRefundCollection
RefundCollection = PTAgreement.RefundsAvailab
Me.SetListing(HttpContext.
BindGrid()
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Public Sub BindGrid()
Try
SetSummary(ValSum)
Dim RefundCollection As PTRefundCollection
Dim al As ArrayList
RefundCollection = Me.GetListing(HttpContext.
al = RefundCollection.GetList
Me.dgSearchResults.DataSou
Me.dgSearchResults.DataBin
Catch ex As PTBusinessException
AddErrorMessage(ex.Message
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
Public Shadows Function GetListing(ByVal oHTTPContext As System.Web.HttpContext) As LifeStyle.Entity.PT.Agreem
Try
SetSummary(ValSum)
Return CType(oHTTPContext.Session
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Function
Public Shadows Sub SetListing(ByVal oHTTPContext As System.Web.HttpContext, ByVal al As LifeStyle.Entity.PT.Agreem
Try
SetSummary(ValSum)
oHTTPContext.Session("sesP
Catch ex As Exception
AddErrorMessage(ex.Message
ExceptionManager.Publish(e
End Try
End Sub
End Class
ASKER
I have figured out my own problem. In the dgSearchResult_itemcommand method, I was not deminsioning ID as an Integer. ID is set to retrieve the datakey value of the item selected. Therefore, ID was defaulting to an object instead of an integer. The object appeared to be removed just fine. However, the viewstate of the datagrid was messed up each time a command button event was correctly firing because I was removing an object instead of a datarow, I believe. Can I reward myself the points? <just kidding>...
- kbailey23342
- kbailey23342
Naa, you can't get your own points (wouldn't that be nice), but they will refund the points you used to ask the question, Just make a request in Community Support to close the question.
https://www.experts-exchange.com/help.jsp#hi70
--Michael
https://www.experts-exchange.com/help.jsp#hi70
--Michael
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
someControlInMyDG.Controls