troubleshooting Question

Setting SqlDataSource Defautl Value for Gridview RowUpdating

Avatar of lakhi
lakhi asked on
ASP.NET
1 Comment1 Solution580 ViewsLast Modified:
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

ASKER CERTIFIED SOLUTION
lakhi

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros