Gridview问题ASP.NET [英] Gridview Problems ASP.NET

查看:87
本文介绍了Gridview问题ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我的asp.net页面上有一个小问题。我有2个gridview,每个都有不同的coloums,都在sql中执行相同的存储过程以带回数据但显示不同的数据。



我的问题是我有下拉列表供用户选择他们想要查看的网格视图。它们一开始工作正常,所以例如如果我选择gridview A显示数据,然后我选择Gridview B并显示数据。现在问题出现了,当我想恢复到Gridview A但gridview B不断显示。



我试图处理和隐藏gridview但是他们都没有出现在屏幕上。

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.

推荐答案

我觉得你的网格价值得到了提升您必须检查您的代码以处理这些缓存的值以获取最新数据...



请给我正确的代码段,以便我能够告诉您或将帮助找出那个解决方案。
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.


这是作为解决方案发布的,但是来自OP的代码。添加了要提问的代码。
This was posted as a solution but is the code from the OP. Added code to question.


感谢您尝试提供帮助,但我已设法让我的代码正常工作。
thanks for trying to help out but I have managed to get my code working.


这篇关于Gridview问题ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆