troubleshooting Question

RowFilter property not working with DataGrid

Avatar of jtrapat1
jtrapat1 asked on
.NET Programming
14 Comments1 Solution314 ViewsLast Modified:
Im trying to pass a letter from an alphabet menu to my SELECT statement as a WHERE clause in order to narrow down the results of my AddressList.
I have a DataGrid, Repeater, and LinkButton:
Heres my code:
-----------------------------------------------
 Sub BindData(ByVal GetFresh As Boolean)
            Dim DTable As DataTable = Nothing
            If ViewState("vsSortData") Is Nothing Or GetFresh Then
                cmd = New SqlCommand("SELECT DISTINCT [general/name] FROM AddressBook ", myConn)
                myDataAdapter = New SqlDataAdapter(cmd)
                Dim DSet As New DataSet()
                Try
                    myDataAdapter.Fill(DSet)
                    DTable = DSet.Tables(0)
                Catch EXC As SqlException
                    Return
                Finally
                    myConn.Close()
                End Try
                ViewState("vsSortData") = DTable
            Else
                DTable = CType(ViewState("vsSortData"), DataTable)
            End If
            If strFilter = "All" Then
                DTable.DefaultView.RowFilter = String.Empty
            Else
                DTable.DefaultView.RowFilter = "[general/name] LIKE '" & strFilter & "%' AND location_id = 1"
            End If
            DTable.DefaultView.Sort = "[general/name] ASC"
            Me.dgAddress.DataSource = DTable.DefaultView
            Me.dgAddress.DataBind()
            BuildAlphaPager()
        End Sub
-------------------------------------------
And strFilter gets filled here:
------------------------------------------------------
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim ThisFilter As Object = ViewState("vsFilter")
            If Not (ThisFilter Is Nothing) Then
                strFilter = CStr(ThisFilter)
            Else
                strFilter = "All"
            End If
            If Not Page.IsPostBack Then
                BindData(True)
            End If
        End Sub
---------------------------------------------------
I'm trying to customize some previously written code and I know the javascript involved is this:
---------------------------
<a id="rptAlpha_ctl04_lnkAlpha" class="letters" href="javascript:__doPostBack('rptAlpha$ctl04$lnkAlpha','')">D</a>
--------------------------

So, when you click on a letter - it should filter the dataset below.
When I click on the letter, it does not filter the data but when I hard-code the sql statement, it does.
Is there any function I can override or add?

Thanks in Advance.

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
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 14 Comments.
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