Tag: sqldatasource

asp:SqlDataSource到DataSet项

我在我的aspx页面上有一个asp:SqlDataSource ID =“SqlDataSource1”工具,我想在c#sharp代码后面做的是传输数据源返回的记录并将它们放入DataSet中,这样我就可以添加分页了我的页面,我该怎么做,到目前为止我的尝试都失败了?! 到目前为止,我的尝试一直是: DataSet Items = new DataSet(); Items = SqlDataSource1.Data(); 但是我得到的错误是在这种情况下无法访问SqlDataSource1控件,所以显然intellisense没有把它拿起来,所以’Data()’位在我看来是完整的小说…… 谢谢,R

在ASPX页面上将“太多参数传递给”存储过程

我无法搞清楚这个错误。 我在ASPX页面上有一个网格,它显示SQL Server 2008数据库中存储过程的数据。 页面加载时,我收到以下错误: “Procedure or function has too many arguments specified.” 这是网格和数据源的代码: <asp:LinkButton ID="ImpersonateUserLinkButton" runat="server" OnClick="Command_Click" CommandName="impersonate" CommandArgument='’ CssClass=”table_command”>Impersonate No data to display. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="” SelectCommand=”sp_GatewayMerchants” SelectCommandType=”StoredProcedure”> 这是存储过程的代码: ALTER PROCEDURE [dbo].[sp_GatewayMerchants] — Add the parameters for the stored procedure here @StartDate DateTime, @EndDate DateTime, @StatusActive bit, @StatusDeactive bit AS BEGIN — […]

将DateTime设置为Gridview的SqlDataSource参数

嘿我想在过去的30天里用我的存储过程显示某些数据。 这是我所做的(aspx.cs文件): protected void Page_Load(object sender, EventArgs e) { DateTime toDate, fromDate; toDate = DateTime.Now; fromDate = toDate.Subtract(new TimeSpan(31, 0, 0, 0)); SqlDataSource1.SelectParameters.Add(“fromDate”, DbType.DateTime, fromDate.ToString()); SqlDataSource1.SelectParameters.Add(“toDate”, DbType.DateTime, toDate.ToString()); } 这是我的aspx文件 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="” SelectCommand=”procCustomer_SelectbyCreationDate” SelectCommandType=”StoredProcedure”> 当我测试这个时,我的屏幕显示为空白(除了母版页元素)并且没有错误。 有任何想法吗?

GridView RowUpdating来自CodeBehind的SqlDataSource.Update

所以我在OnRowUpdating事件期间在Gridview中进行更新时遇到问题。 我想要做的是在SqlDataSource中设置UpdateCommand,然后使用该命令进行更新。 事件发生正常,但是当事件完成时,行似乎永远不会更新。 C#: protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { SqlDataSource1.UpdateCommand = “UPDATE A_Table SET Something = @AValue WHERE ID = ” + e.RowIndex; SqlDataSource1.Update(); } 编辑:重新编写我的示例更新命令…它实际上是一个更新命令,而不是一个选择命令哈哈。

SQLDatasource参数

如何在后面的代码中为sqlDatasource设置sql参数? 我这样想: int id=1; SqlDataSource1.SelectCommand = “SELECT * FROM categ WHERE id=@id”; SqlDataSourceArticole.SelectParameters.Add(“@id”, id); // and also like this: SqlDataSourceArticole.SelectParameters.Add(“id”, id); 但它不起作用? 我究竟做错了什么?

如果使用自定义DataSource,如何对ASP.NET GridView中的列进行排序?

当我使用自定义SqlDataSource时,我无法使用GridView使用户能够对数据列进行排序。 我有一个GridView,其中HTML中引用它的代码是最小的: 在代码隐藏中,我附加了一个动态创建的SqlDataSource(它包含的列并不总是相同,因此用于创建它的SQL是在运行时构造的)。 例如: 我设置了专栏…… BoundField column = new BoundField(); column.DataField = columnName; column.HeaderText = “Heading”; column.SortExpression = columnName; grid.Columns.Add(column); 数据源…… SqlDataSource dataSource = new SqlDataSource( “System.Data.SqlClient”, connectionString, generatedSelectCommand); 那么gridview …… grid.DataSource = dataSource; grid.DataKeyNames = mylistOfKeys; grid.DataBind(); 当我希望它对列数据进行排序时,当用户点击列标题时,没有任何反应。 任何想法,我缺少什么? 如果有一个更好的方式这样做也会有所帮助,因为这对我来说看起来很麻烦!

如何在GridView EditTemplate中设置DropDownList的SelectedValue

我正在尝试这样做,如前所述。 我找到的唯一区别是上面代码中包含的附加List项。 我试图使用AppendDataBoundItems=true但它仍然无法正常工作。 我还想将其默认值设置为itemtemplate标签中显示的值,即DropDownList的SelectedValue=”但是我在下拉列表中无法使用该属性。 可能是什么原因。 ?? <asp:SqlDataSource ID="dsDepartment_Edit" runat="server" ConnectionString="” ProviderName=”System.Data.SqlClient” SelectCommand=”sp_GetDepartmentDropDown” SelectCommandType=”StoredProcedure”> <asp:Label ID="lblDepartmentName" runat="server" Text='’ > 我正在使用GridView

尽管sqldatasource有值,但是为空gridview

我真的很奇怪。 我创建了新的aspx页面,并且没有使用任何自定义逻辑对象(使用visual studio向导创建的所有内容)尝试从sqldatasource创建网格视图。 数据来自存储过程,单个参数具有默认值。 当我刷新架构或单击“测试查询”时,我看到结果行和GridViews字段是核心创建的。 但是当我运行页面时,没有网格视图(它只是空的 – 当我添加EmptyDataTemplate时会显示它)。 我添加了自定义(空)函数和DataBind,DataBinded和RowCreted事件,并且只触发了databind和datavound事件(尽管如我所写 – 存储过程及其默认参数返回行和.net可以在设计模式下读取它们) 程序中没有任何“花哨”的东西,我已经做了不止一次没有问题。 我已经尝试了另一个在我们的生产环境中工作的存储过程,并且仍然具有相同的emty gridview 这是代码 Untitled Page No Data Available <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="” SelectCommand=”myStoredProcedure” SelectCommandType=”StoredProcedure”> 和代码隐藏 using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace site { public […]

带有合并单元格的GridView

我需要在网格视图中显示数据,并为某些列合并行。 请帮我准备以下定义格式的网格视图: 而来自数据库的原始数据格式如下: 请帮助我找到动态有效地完成此任务的最佳方法。