从存储过程中的数据列表填充 [英] Data List populated from stored procedure

查看:148
本文介绍了从存储过程中的数据列表填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是在短短5步一个具体的例子:

Here's a concrete example in 5 short steps:

1)我已经在一个ASCX文件的设计视图中建立了一个数据列表。

1) I have built a Data List in the Design view of an "ASCX" file.

2)在数据列表中的项目模板区域,我创建了一个1×3的表,并在每个小区我指定如下使用eval(columnx)的柱(FID)通过存储过程返回。

2) In the Item Template area of the Data List, I created a 1x3 table, and in each cell I specified as below using Eval("columnx") a column (fid) returned through a Stored Procedure.

< ASP:标签ID =Label1的=服务器文本='<%#的eval(FID)%>'>

<asp:Label ID="Label1" runat="server" Text='<%# Eval("fid") %>'>

在以相同的方式,我指定由相同的存储过程返回其他两个字段

In the same manner, I specified other two fields returned by the same stored procedure.

3)我去.ASCX.CS(隐藏文件code)和指定的数据源作为是存储过程;我做了数据绑定:

3) I went to the .ASCX.CS (code behind file) and specified the data source as being the stored procedure; and I did the data binding:

DataList1.DataSource = FilmsAccess.GetFilms(); DataList1.DataBind();

PS:FilmsAccess是APP_ code包含GetFilms内部类(),其中存储过程GetFilms传递和执行方法。 SP的结果是一个数据表。

PS: FilmsAccess is a class inside App_Code that contains the GetFilms() method where the GetFilms stored procedure is passed and executed. The result of the SP is a datatable.

4)我去了我的母版页和复制的数据表那里,里面的ContentPlaceHolder

4) I went to my master page and copied the data list there, inside a contentplaceholder.

5)我创建了一个名为Catalog.aspx页面,从主继承。我默认了的ContentPlaceHolder什么大师显示了从设计视图。
其结果是,目录打开,但我没有看到DataList控件 - 在所有。我在做什么错了?感谢您阅读和跟进!

5) I created a page called Catalog.aspx that inherits from the master. I defaulted its ContentPlaceHolder to what the master shows from design view. As a result, Catalog opens, but I don’t see the datalist - AT ALL. What am I doing wrong?? Thank you for reading and following up!

推荐答案

我找到了答案:步骤4)上面是错误的。而不是复制包含在ASCX文件内的数据列表中的,需要拖放整个的ascx文件到需要的地方(在此情况下,成Catalog.aspx)!有一个愉快的一天大家!

I have the answer: Step 4) above was wrong. Instead of copying the data list contained within the ascx file, one needs to drag and drop the entire ascx file into where it is needed (in this case, into Catalog.aspx)! Have a nice day everyone!

这篇关于从存储过程中的数据列表填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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