English 中文(简体)
重复数据集和细列数据集的距离问题——只有最后一行显示
原标题:Strange issue with repeater and cached dataset - only last row shown

我的法典较为简单:

        Dim oShow As DataSet = Nothing
        Dim cacheKey As String = String.Format("AsyncCacheFor_agenda_{0}", ShowID)

        If Not IsNothing(Cache(cacheKey)) Then
            oShow = DirectCast(Cache(cacheKey), DataSet)
        Else
            oShow = DataServers.dsTMW.GetAgenda(ShowID, 0, "", 0, True)
            Cache.Insert(cacheKey, oShow, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, New TimeSpan(1, 0, 0))
        End If
        phSearch.Visible = True


        oShowRow = oShow.Tables(0).Rows(0)


        oTracks = oShow.Tables(1)
        oSearchResults = oShow.Tables(5)


        If Not IsNothing(oSearchResults) AndAlso oSearchResults.Rows.Count > 0 Then
            rptSearch.Visible = True
            phNoResults.Visible = False
            rptSearch.DataSource = oSearchResults
            rptSearch.DataBind()
        Else
            rptSearch.Visible = False
            phNoResults.Visible = True

        End If

“密码”是一种<代码>Repeater,Get agenda()法则通过存储程序从数据库中读取数据集。 该数据集有6个不同的表格。 当数据集从数据库读到时,<代码>Repeater显示36行,预期结果。 阅读时,只显示一行,最后一行。 奇怪的是,当我去bug时,我看见oSearchResults.Rows.Count = 36

是否有人想为什么会发生这种情况?

最佳回答

我列举了这一问题。 我在项目DataBound活动中这样做:

Dim dvRows As DataView = oSearchResults.DefaultView
dvRows.RowFilter = String.Format("Submission_id={0} AND speaker_id Is Not Null", oRow("Submission_id"))

一俟我改为:

Dim dvRows As DataView = oSearchResults.Copy().DefaultView

问题消失了。 我不禁要问,为什么这只是一个问题。

问题回答

真正看看它是否与海滩有任何关系,总是利用海滩的数据集。 在检查中,看看它是否在海滩上,而不是去上下数据集,然后使用数据集。

So, rather than this:

If Not IsNothing(Cache(cacheKey)) Then
    oShow = DirectCast(Cache(cacheKey), DataSet)
Else
    oShow = DataServers.dsTMW.GetAgenda(ShowID, 0, "", 0, True)
    Cache.Insert(cacheKey, oShow, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, New TimeSpan(1, 0, 0))
End If

这是:

If IsNothing(Cache(cacheKey)) Then
    oShow = DataServers.dsTMW.GetAgenda(ShowID, 0, "", 0, True)
    Cache.Insert(cacheKey, oShow, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, New TimeSpan(1, 0, 0))
End If

oShow = DirectCast(Cache(cacheKey), DataSet)

这赢得了“固定”你的问题,但会缩小问题。 如果你总是一行,那么你就知道它必须把数据输入海滩。 如果我不得不猜测,我可以说,在你的法典之外还有其他一些事情。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签