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)
    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
      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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.