Is it possible to have Dirtyrows ignore controls?

Topics: Developer Forum, User Forum
Dec 11, 2007 at 8:56 PM
I have a gridview that dynamically adds controls to a row. If the control is a checkbox or a dropdownlist, I include a hidden textbox in the same cell. When I have all textboxes, the dirtyrows work great. When the row contains a dropdown or a checkbox it is always being flagged as changed. Can I flag the controls to not be included in the check for changes?

Protected Sub BulkEditGridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles BulkEditGridView1.PreRender
Dim row As GridViewRow
Dim cell As TableCell
Dim txtResponse As New TextBox
Dim sFieldLabel As String
Dim sTemp As String
For Each row In BulkEditGridView1.Rows
For Each cell In row.Cells
Select Case row.Cells.GetCellIndex(cell)
Case 3 'Response
txtResponse = cell.Controls(0)
sFieldLabel = row.Cells(1).Text
Dim myLabel As New fieldLabel(sFieldLabel)
Select Case myLabel.sType
Case "Gen", "Date"
txtResponse.MaxLength = myLabel.sSize
txtResponse.Columns = 50
Case "Num"
txtResponse.Columns = 5
Case "Cbx"
Dim cbxTemp As New CheckBox
sTemp = txtResponse.Text
txtResponse.Width = 4
txtResponse.CssClass = "hideTextBox"
txtResponse.Text = sTemp
cbxTemp.ID = "atCbx"
If sTemp = "Y" Then
cbxTemp.Checked = True
Else
cbxTemp.Checked = False
End If
cbxTemp.EnableViewState = True
cbxTemp.Attributes.Add("onclick", "getIndex(this);")
cell.Controls.AddAt(0, cbxTemp)
Case "YNA"
Dim ddlTemp As New DropDownList
Dim tempItem0 As New ListItem
sTemp = txtResponse.Text
tempItem0.Text = "Select"
tempItem0.Value = ""
ddlTemp.Items.Add(tempItem0)
Dim tempItem1 As New ListItem
tempItem1.Text = "Yes"
tempItem1.Value = "Yes"
ddlTemp.Items.Add(tempItem1)
Dim tempItem2 As New ListItem
tempItem2.Text = "No"
tempItem2.Value = "No"
ddlTemp.Items.Add(tempItem2)
Dim tempItem3 As New ListItem
tempItem3.Text = "N/A"
tempItem3.Value = "N/A"
ddlTemp.Items.Add(tempItem3)
ddlTemp.SelectedValue = sTemp
txtResponse.Width = 4
txtResponse.CssClass = "hideTextBox"
txtResponse.Text = sTemp
ddlTemp.ID = "atDDL"
ddlTemp.EnableViewState = True
ddlTemp.Attributes.Add("onclick", "getDDLvalue(this);")
cell.Controls.AddAt(0, ddlTemp)
End Select
Case Else
'do nothing
End Select
Next
Next
End Sub