Click here to Skip to main content
15,915,163 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi there,

I have a small problem on my asp.net page. I have 2 gridview, each one with different coloums, both execute the same stored procedure in sql to bring back data but show different data.

My problem is that I have drop down list for the user to select which gridview they'd like to see. they both work fine at first, so for example if I select gridview A the data is displayed, I then select Gridview B and the data displays. Now the problem arises when I want to revert back to Gridview A but gridview B keeps getting displayed.

I have tried to dispose and hide the gridview but then they both never appear on screen.
If ddlView.SelectedValue = "Default View" Then
               gvFiles.DataSource = cmd.ExecuteReader()
               gvFiles.DataBind()
               If gvFiles.Rows.Count > 0 Then
                   butDownload.Visible = True
                   butReset.Visible = True
                   butZip.Visible = True
                   pnlLinks.Visible = True
                   butDownload1.Visible = True
                   butZip1.Visible = True
                   butReset1.Visible = True
               Else
                   Dim sb As New System.Text.StringBuilder()
                   Dim message As String = "No Record Found"
                   sb.Append("<script type = 'text/javascript'>")
                   sb.Append("window.onload=function(){")
                   sb.Append("alert('")
                   sb.Append(message)
                   sb.Append("')};")
                   sb.Append("</script>")
                   ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", sb.ToString())
               End If
           End If
           If ddlView.SelectedValue = "Classification View" Then
               gvFiles.Dispose()
               gvFiles.DataSource = Nothing
               gvFiles.DataBind()
               gvFiles.Visible = False
               gvClassification.DataSource = cmd.ExecuteReader()
               gvClassification.DataBind()
               If gvClassification.Rows.Count > 0 Then
                   butDownload.Visible = True
                   butReset.Visible = True
                   butZip.Visible = True
                   pnlLinks.Visible = True
                   butDownload1.Visible = True
                   butZip1.Visible = True
                   butReset1.Visible = True
               Else
                   Dim sb As New System.Text.StringBuilder()
                   Dim message As String = "No Record Found"
                   sb.Append("<script type = 'text/javascript'>")
                   sb.Append("window.onload=function(){")
                   sb.Append("alert('")
                   sb.Append(message)
                   sb.Append("')};")
                   sb.Append("</script>")
                   ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", sb.ToString())
               End If
           End If



this is all behind my search function

Any suggestions?

Thanks.
Posted
Updated 11-Mar-13 5:18am
v2
Comments
pradiprenushe 11-Mar-13 5:50am    
Need your code to see

1 solution

It seemsto me that your grid value gets cahced and you have to check your code to disposed those cached values to get the fresh data...

Please give me proper code snippet so I can able to tell you or will help to find out the soluton of that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900