это код aspx
enter code here
Dim objCreditLimits As SCU.DataAccess.Layer.clsCreditLimits = New SCU.DataAccess.Layer.clsCreditLimits
Dim objSystemData As SCU.DataAccess.Layer.clsSystemData = New SCU.DataAccess.Layer.clsSystemData
Protected Sub Page_LoadComplete(sender As Object, e As System.EventArgs) Handles Me.LoadComplete
litMemberID.Text = " - " & Request.QueryString("MemberID")
End Sub
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad
If Request.QueryString("a") = "logout" Then
Session.Abandon()
Response.Redirect("StaffLogin.aspx")
End If
If Session("StaffID") Is Nothing Then
' Response.Redirect("StaffLogin.aspx")
End If
End Sub
Sub gvMember_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
'If e.Row.RowType = DataControlRowType.DataRow Then
' Dim arguments As String = ("01/01/1900").ToString
' DataBinder.Eval(e.Row.DataItem, "EndDate").ToString()
' If arguments = "01/01/1900" Then
' Dim text As TextBox = DirectCast(e.Row.FindControl("txtEndDate"), TextBox)
' End If
'End If
End Sub
Sub gvBatches_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim arguments As String = ("01/01/1900").ToString
DataBinder.Eval(e.Row.DataItem, "EndDate").ToString()
If arguments = "01/01/1900" Then
Dim text As TextBox = DirectCast(e.Row.FindControl("txtEndDate"), TextBox)
'text.Text = String.Empty
End If
End If
End Sub
'If e.Row.RowType = DataControlRowType.DataRow Then
' Dim hfDuplicated As HiddenField = CType(e.Row.FindControl("hfDuplicated"), HiddenField)
' Dim hfSuccessfulBacs As HiddenField = CType(e.Row.FindControl("hfSuccessfulBacs"), HiddenField)
' Dim lblName As Label = CType(e.Row.FindControl("lblName"), Label)
' If e.Row.RowState = DataControlRowState.Normal OrElse e.Row.RowState = DataControlRowState.Alternate Then
' If CBool(hfDuplicated.Value) Then
' lblName.ForeColor = Drawing.Color.Red
' ElseIf CBool(hfSuccessfulBacs.Value) Then
' lblName.ForeColor = Drawing.Color.Green
' End If
' End If
'End If
Protected Sub btnSave_Click(sender As Object, e As System.EventArgs) Handles btnSave.Click
Try
Dim memberID As Int64 = Request.QueryString("MemberID")
Dim UserID As Integer = Session("StaffID")
Dim txtProductAmountLimit As TextBox = Nothing
Dim hfProductAmountLimit As HiddenField = Nothing
Dim txtProductCountLimit As TextBox = Nothing
Dim hfProductCountLimit As HiddenField = Nothing
Dim txtNote As TextBox = Nothing
Dim txtEndDate As TextBox = Nothing
Dim EndDate As Date = "01/01/1900"
Dim Today As String = Date.Today.ToString("dd/MM/yyyy")
Dim lblNoteRequired As Label = Nothing
Dim hfCreditLimitProductID As HiddenField = Nothing
Dim hfEndDate As HiddenField = Nothing
Dim creditLimit As Double = 0
Dim annualLimit As Double = 0
Dim saveChanges As Boolean = False
Dim noErrors As Boolean = True
lblMessage.Text = ""
For Each gridRow As GridViewRow In gvMemberList.Rows
txtProductAmountLimit = CType(gridRow.Cells(0).FindControl("txtProductAmountLimit"), TextBox)
hfProductAmountLimit = CType(gridRow.Cells(0).FindControl("hfProductAmountLimit"), HiddenField)
txtProductCountLimit = CType(gridRow.Cells(0).FindControl("txtProductCountLimit"), TextBox)
hfProductCountLimit = CType(gridRow.Cells(0).FindControl("hfProductCountLimit"), HiddenField)
hfCreditLimitProductID = CType(gridRow.Cells(0).FindControl("hfCreditLimitProductID"), HiddenField)
txtNote = CType(gridRow.Cells(0).FindControl("txtNote"), TextBox)
txtEndDate = CType(gridRow.Cells(0).FindControl("txtEndDate"), TextBox)
hfEndDate = CType(gridRow.Cells(0).FindControl("hfEndDate"), HiddenField)
Dim EndD As Date = "01/01/1900"
Date.TryParse(IIf(String.IsNullOrEmpty(txtEndDate.Text), "01/01/1900", txtEndDate.Text), EndD)
If Not String.IsNullOrEmpty(txtEndDate.Text) AndAlso Not Date.TryParse(txtEndDate.Text, EndDate) Then
lblMessage.Visible = True
lblMessage.Text = "Invalid end date"
Exit Sub
End If
lblNoteRequired = CType(gridRow.Cells(0).FindControl("lblNoteRequired"), Label)
Double.TryParse(txtProductAmountLimit.Text, creditLimit)
Integer.TryParse(txtProductCountLimit.Text, annualLimit)
If txtNote.Text.Length = 0 AndAlso (creditLimit <> CDbl(hfProductAmountLimit.Value) OrElse annualLimit <> CInt(hfProductCountLimit.Value)) Then
lblNoteRequired.Visible = True
noErrors = False
lblMessage.Text = "Please enter a note for each credit limit you would like to amend"
Else
lblNoteRequired.Visible = False
End If
EndDate = IIf(String.IsNullOrEmpty(txtEndDate.Text), "01/01/1900", IIf(Date.TryParse(txtEndDate.Text, EndDate), txtEndDate.Text, "01/01/1900"))
If (txtEndDate.Text.Length = 0 Or Date.Compare(EndD, Today) > 0) Then
If txtNote.Text.Length > 0 AndAlso (creditLimit <> CDbl(hfProductAmountLimit.Value) OrElse annualLimit <> CInt(hfProductCountLimit.Value) OrElse IIf(Date.TryParse(txtEndDate.Text, EndD), txtEndDate.Text, "01/01/1900") <> CDate(hfEndDate.Value)) Then
objCreditLimits.InsertUpdateCreditLimitProduct(memberID, hfCreditLimitProductID.Value, creditLimit, annualLimit, txtNote.Text, EndDate, UserID)
saveChanges = True
End If
ElseIf (Date.Compare(EndD, Today) < 0) Then
lblMessage.Visible = True
noErrors = False
lblMessage.Text = "Please enter a furter end date"
Exit Sub
End If
Next
If saveChanges AndAlso noErrors Then
odsCreditLimits.Select()
gvMemberList.DataBind()
End If
Catch ex As Exception
objSystemData.InsertErrorLog(ex, Request.ServerVariables("REMOTE_ADDR"))
lblMessage.Visible = True
lblMessage.Text = ex.Message
End Try
End Sub
Конечный класс
вместо сравнения на странице asp, я также пытаюсь выполнить событие rowdatabound
Необходимо присвоить нуль для столбца Дата-дата-сетки, когда нет данных для отображения.но sql назначить DateTime.MinValue для этого.нужно изменить это. Не могли бы вы помочь мне.По умолчанию назначьте «01/01/1900», когда нет данных, относящихся к EndDate. Я хочу отобразить пустое текстовое поле, если EndDate «01/01/1900» см. Вывод