Solved

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

Posted on 2004-05-02
8
342 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now