P
Plateriot
I have a gridview that I have multiple filters which I have set up in the
header template of a gridview...
This gridview already has an object data source called: "odsTargetCases"
My following example of the one combobox as a filter is working with the
exception of two things:
1) If I select the default value '*All*' AFTER successfully filtering a
gridview - the gridview comes up blank.
2) If I sort any of the other fields, the gridview also comes up blank
I use 'BindTargetGridview' to 'adjust' the object data source depending on
if any combobox has been selected.
Private Sub BindTargetGridview()
Dim condition As String = Nothing
If gvTarget.HeaderRow IsNot Nothing Then
Dim cmbPCP As DropDownList =
DirectCast(gvTarget.HeaderRow.FindControl("cmbTargPCP"), DropDownList)
strTargetPCP = cmbPCP.SelectedValue
If cmbPCP.SelectedValue <> "*All*" Then
condition = "ProvName='" & strTargetPCP & "'"
End If
End If
If condition IsNot Nothing Then
odsTargetCases.FilterExpression = condition
End If
gvTarget.DataSourceID = ""
gvTarget.DataSourceID = "odsTargetCases"
gvTarget.DataBind()
End Sub
I also put this logic in the RowDataBound event to 'retain' the selected
value that a use selects in a variable called strTargetPCP:
Protected Sub gvTarget_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
Dim cmbPCP As DropDownList =
DirectCast(e.Row.FindControl("cmbTargPCP"), DropDownList)
cmbPCP.SelectedValue = strTargetPCP
End If
End Sub
Finally, I put the BindTargetGridview routine in the Sorting event of the
gridview
Protected Sub gvTarget_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs)
BindTargetGridview()
End Sub
I can't figure out why I don't see the sort results (comes up blank after
soring) , or why whenever I select the default value (*All*) the gridview
comes up blank -- ??
header template of a gridview...
This gridview already has an object data source called: "odsTargetCases"
My following example of the one combobox as a filter is working with the
exception of two things:
1) If I select the default value '*All*' AFTER successfully filtering a
gridview - the gridview comes up blank.
2) If I sort any of the other fields, the gridview also comes up blank
I use 'BindTargetGridview' to 'adjust' the object data source depending on
if any combobox has been selected.
Private Sub BindTargetGridview()
Dim condition As String = Nothing
If gvTarget.HeaderRow IsNot Nothing Then
Dim cmbPCP As DropDownList =
DirectCast(gvTarget.HeaderRow.FindControl("cmbTargPCP"), DropDownList)
strTargetPCP = cmbPCP.SelectedValue
If cmbPCP.SelectedValue <> "*All*" Then
condition = "ProvName='" & strTargetPCP & "'"
End If
End If
If condition IsNot Nothing Then
odsTargetCases.FilterExpression = condition
End If
gvTarget.DataSourceID = ""
gvTarget.DataSourceID = "odsTargetCases"
gvTarget.DataBind()
End Sub
I also put this logic in the RowDataBound event to 'retain' the selected
value that a use selects in a variable called strTargetPCP:
Protected Sub gvTarget_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
Dim cmbPCP As DropDownList =
DirectCast(e.Row.FindControl("cmbTargPCP"), DropDownList)
cmbPCP.SelectedValue = strTargetPCP
End If
End Sub
Finally, I put the BindTargetGridview routine in the Sorting event of the
gridview
Protected Sub gvTarget_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs)
BindTargetGridview()
End Sub
I can't figure out why I don't see the sort results (comes up blank after
soring) , or why whenever I select the default value (*All*) the gridview
comes up blank -- ??