• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 563
  • Last Modified:

Setting SqlDataSource Defautl Value for Gridview RowUpdating

The gridview I'm using in this application will be used by the admin for the web application. The admin will have the capability to edit almost all of the fields in each record. The admin can also close the record from this form. To make it as easy as possible for the user, I want the gridview updating to check for a close date. If a close date is entered, the user must also select "Yes" or "No" from the redline dropdown (default is "UNKNOWN"). I have customvalidators that are enabled when a close date is entered and they work properly.
Once the close date and dropdown are validated, I want to change the priority field to "DONE" and the tool_design_complete_date to today's date.
Everything works except for changing the priority value and I can't figure out why.
Help, please?
Protected Sub adminPendGridview_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles adminPendGridview.RowUpdating
    'Complete Date
    Dim dtTB As TextBox = CType(adminPendGridview.Rows(e.RowIndex).FindControl("completeDateTextBox"), TextBox)
    'Tool Design Complete Date
    Dim dt2TB As TextBox = CType(adminPendGridview.Rows(e.RowIndex).FindControl("toolDsgnCptDtTextBox"), TextBox)
    'Priority
    Dim priTB As TextBox = CType(adminPendGridview.Rows(e.RowIndex).FindControl("priorityTextBox"), TextBox)
    'Redline Dropdown
    Dim rdDDL As DropDownList = CType(adminPendGridview.Rows(e.RowIndex).FindControl("redlineDropDownList"), DropDownList)
    'Complete Date CustomValidator
    Dim custVal As CustomValidator = CType(adminPendGridview.Rows(e.RowIndex).FindControl("compDtCustomValidator"), CustomValidator)
    'Redline CustomValidator
    Dim rdCustVal As CustomValidator = CType(adminPendGridview.Rows(e.RowIndex).FindControl("redlineCustomValidator"), CustomValidator)

    'Check to see if the Close Date has been entered. 
    'If so, enable the custom validator to check the validity of the text entered and
    'enable the custom validator for the redline dropdownlist
    If IsDate(dtTB.Text) Then
      custVal.Enabled = True
      rdCustVal.Enabled = True
    Else
      custVal.Enabled = False
      rdCustVal.Enabled = False
    End If


    If (IsDate(dtTB.Text)) Then 'a complete date has been entered and the Redline dropdown is Yes or No
      If priTB.Text <> "DONE" Then AdminPendSqlDataSource.UpdateParameters("priority").DefaultValue = "DONE"
      If Not IsDate(dt2TB.Text) Then AdminPendSqlDataSource.UpdateParameters("tool_design_complete_date").DefaultValue = Now.ToShortDateString
    End If
  End Sub

Open in new window

0
lakhi
Asked:
lakhi
1 Solution
 
lakhiAuthor Commented:
This is actually a version of a question I asked earlier. I wound up fixing it by using a combination of things. I set the priority to "DONE" in the SqlDataSource_Updating.
I'm attaching the code that worked. Guess I'm still confused as to why it works for one parameter in the gridview_rowupdating but not for both :(

Protected Sub AdminPendSqlDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles AdminPendSqlDataSource.Updating
    If IsDate(e.Command.Parameters("@complete_date").Value) Then
      e.Command.Parameters("@priority").Value = "DONE"
    End I

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now