Solved

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

Posted on 2004-05-02
8
361 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
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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