简体   繁体   English

在LinqDataSource中使用存储的proc来填充GridView

[英]Using stored proc in LinqDataSource to populate GridView

As in the title I need to use stored proc to feed LinqDataSource to populate result in GridView. 如标题中所示,我需要使用存储的proc来提供LinqDataSource来在GridView中填充结果。 I got this concept to work in SqlDataSource but then I had Authentication issues (I'm running the app on tablets that can't provide Integrated Authentication that SQL Server requires - and I do not want to change SQL configuration). 我让这个概念可以在SqlDataSource中使用,但是随后出现了身份验证问题(我在无法提供SQL Server所需的集成身份验证的平板电脑上运行该应用程序,并且我不想更改SQL配置)。 Linq works perfectly for me except when I try to use Calendar control to feed WHERE parameter. 除了当我尝试使用Calendar控件输入WHERE参数时,Linq对我而言非常理想。 The stored proc worked much better and I could receive correct sets but now I have problems populating that to GridView. 存储的proc工作得更好,我可以收到正确的集,但是现在我在将其填充到GridView时遇到了问题。

Here is the code: 这是代码:

protected void myLinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    DataContext myContext = new DataContext();
    e.Result = myContext.myTable(myCalendar.SelectedDate);
}

protected void myCalendar_SelectionChanged(object sender, EventArgs e)
{
    myLinqDataSource.DataBind();
    myGridView.DataBind();
}

In this configuration the pool times out. 在此配置中,池超时。 If I move binding to event handler, there would be nothing supplied to grid view. 如果我将绑定移动到事件处理程序,则网格视图将没有任何内容。 Maybe you know a better way to use stored procs with LinqDataSources? 也许您知道将存储的proc与LinqDataSources一起使用的更好方法?

So since there was no answers here is one that I arrived at. 因此,由于没有答案,因此我得出了一个答案。 LinqDataSource is great but pretty hard to configure declaratively. LinqDataSource很棒,但是很难以声明方式进行配置。 I used LDS dynamically to feed set into a List<>() and bound GridView to it. 我动态地使用LDS将集合输入List <>()并将GridView绑定到它。 Worked perfectly! 工作完美!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM