Solved

How to rebind bound columns in a datagrid after a data rebind

Posted on 2004-05-02
8
385 Views
Last Modified: 2010-04-07
I have a datagrid on as aspx page. The datagrid has a bound column so the user can drill down using a key field.
The user has available a couple of radio buttons which trigger the grid to be rebound using filtered data. When the grid redisplays with the new data, the bound column row index structure has not been updated. Clicking on, say, the first row returns the key for the ORIGINAL first row, rather than the filtered first row.
Can anyone help as to how to overcome this problem.
Thanks in advance
0
Comment
Question by:ajmac-b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 10975409
when you use bound columns it is matter how do you bound it ( the information that you give to it )
so when in the first time you have for example for the 3rd row index 3 and in the rebound datagrid you have again 3 instead of 5, then you just give it 3 instead of 5

you have to check how do you feel the column that returns data in this column, or you can paste the code so the EE can help you

B..M
0
 
LVL 2

Expert Comment

by:SirCaleb
ID: 10978090
I fought this same problem for two days ... I figured out why it happens but I don't remember all of the details.  I wish I could provide you more information but I can tell you that you probably will not find a non-spaghetti way around this problem. :(
0
 

Author Comment

by:ajmac-b
ID: 10982228
Thanks for your replies - I hope the solution is not as complicated as you say, SirCaleb.
The code used to bind the grid (DG) is as follows. I think its pretty standard:

Public Function fillDG(ByVal sid As String, ByVal SortField As String, ByVal optnum As Integer)
        Dim sortorder As String
        Dim sql As String
        Dim sf As String
        Dim cmd As SqlCommand
        Dim rdr As SqlDataReader
        sf = Session("SortField")
        sortorder = Session("SortOrder")
        Select Case optnum
            Case 1  'Registered
                sql = "Select * from [ccq_Claims2] where [StoreID] like '" & sid & "' and [Approved] = 0"
            Case 2
                sql = "Select * from [ccq_Claims2] where [StoreID] like '" & sid & "' and [Approved] > 1"
            Case Else
                sql = "Select * from [ccq_claims2] where [StoreID] like '" & sid
        End Select
        sConWEBSERVER.Open()  'Globally defined conenction string
        cmd = New SqlCommand(sql, sConWEBSERVER)
        rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
        dg.DataSource = rdr
        dg.DataBind()
        sConWEBSERVER.Close()
    End Function
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:mmarinov
ID: 10984055
this function is fine to me and i don't see any problem, but do you have ItemDataBound event or do something with that index bound column
what actually is displaied in it ? may be will be easy if you can post some of your html and if you have some events to your datagrid

B..M
0
 

Author Comment

by:ajmac-b
ID: 10984142
I eventually gave up on a bound Column (ButtonColumn) as the replies here and elsewhere were not very encouraging. I used Hyperlinkcolumns instead.
If anyone else has the same problem - the Hyperlink key solution works fine.
To solve the problem, in the datagrid properties page, open the columns collection
and add a hyperlink button. Set the TextField to the data field needed, then specify the url (In my case this was 'Claims.aspx'), and the Display to the same thing.
You also have to set the URL Format string to something like:  'Claims.aspx?ID={0}

The objective was to pass a key number to another page when the button was clicked, so I decided that using a request.querystring approach might be easier.

Thanks guys for the encouragement. What do I do with the points?
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10984368
because you find a solution to your problem by yourself you don't have award points
if you think that some of answers are helped to you to find the solution you can award it/them with a lower than A Grade ( for grades look here http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP.NET/help.jsp#hi73 )

if you don't want to award answers, you have to post a question in the Community Support to delete your question and return your points

B..M
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 11021513
Closed, 75 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question