Solved

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

Posted on 2004-05-02
8
368 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 47
Winform Module - What is the ASP.Net equiv 2 28
asp.net mvc5 6 20
ASP.NET Content Page 3 25
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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