sqldatasource

ASP.NET - Trying to implement SortParameterName property to SqlDataSource

隐身守侯 提交于 2019-12-12 01:08:46
问题 I have several Gridviews and Repeaters bound to SqlDataSources using stored procedures. I am trying to implement sorting functionality into some of these but am having a hard time finding concrete instructions and/or examples of what is required on the SqlDataSource side to generate the ORDER BY's needed. Particularly, I do not understand the point of having a SortParameterName property in the SqlDataSource if all it does is manually connect to an ORDER BY clause in the stored procedure. Why

Question Mark as Query Parameter?

对着背影说爱祢 提交于 2019-12-11 19:19:57
问题 I have stumbled upon a DataSource sample at http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.querystringparameter(v=vs.100).aspx The code is as follows <%@Page Language="C#" %> <%@Import Namespace="System.Data" %> <%@Import Namespace="System.Data.Common" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> private void UpdateRecords(Object source, EventArgs e) { // This method is

How to delete data from gridview which is using datasource and SP using Wizard

橙三吉。 提交于 2019-12-11 18:46:24
问题 I am using a gridview to select, delete and update data in database. I have written a single SP for doing all these operation. Based on a parameter SP decides which operation to perform. Here is the image of my gridview image of my grid http://www.freeimagehosting.net/uploads/0a5de50661.jpg <asp:GridView ID="GridView1" runat="server" DataSourceID="dsDomain" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="DomainId" > <Columns> <asp:CommandField ShowDeleteButton

Dynamic query in ASP.Net (WHERE clause in SQLDataSource)

a 夏天 提交于 2019-12-11 15:41:04
问题 I'm currently trying to loop through an array (two values) and use both values in a query inside the loop. Please see code below. Right now my code doesn't work. I'm trying to populate dynamically the "appType" parameter within the "SelectParameters" tags of the SQLDataSource, but this won't work. Any suggestion? <% Dim appTypes() As String = {"Extranet", "Internet"} For Each appType As String In appTypes %> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ProviderName = "<%$

SqlDataSource set SelectCommand dynamically

人走茶凉 提交于 2019-12-11 14:30:06
问题 I'm using a SqlDataSource and to avoid writing long queries directly in my code I thought I could make a Query class that returns the query I want as a string. I tried the code below but I just get "Server tags cannot contain <% ... %> constructs." Before I was using stored procedures but my webhosting doesn't allow that, so thats when I thought about the Query class solution. I also need to add that I don't want to do databinding in codebehind. Is there a way of doing this? <asp

Binding GridView to SqlDataSource programmatically

只谈情不闲聊 提交于 2019-12-11 11:32:58
问题 I'm trying to replicate the binding in my markup with something programmatic. It seems I am forced to use a dataset to bind to rather than a SqlDataSource as shown in my markup. Furthermore, when using a dataset, I suddenly lose paging, sorting, etc., and get errors that I need to handle them manually. They were handled automatically before?? So here is my markup: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="

ASP.NET SqlDataSource, like on SelectCommand

烈酒焚心 提交于 2019-12-11 09:14:47
问题 I'm working on asp.net. I Have a SqlDataSource with a query hardcoded on selectcommand: <asp:SqlDataSource ID="DataSource1" runat="server" CancelSelectOnNullParameter="False" ConnectionString="<%$ ConnectionStrings:S.Properties.Settings.ConnectionString %>" SelectCommand="SELECT * FROM [table] WHERE ([col1] like Case @col1_param When null Then col1 Else @col1_param End) and ([col2] like Case @col2_param When null Then col2 Else @col2_param End)" SelectCommandType="Text"> <SelectParameters>

Generating CSV file from SqlDataSource/GridView

≡放荡痞女 提交于 2019-12-11 07:33:26
问题 I need to be able to generate a basic CSV file of the results returned from an SqlDataSource/GridView upon the user clicking a button, then allow them to save this file. Is this simple to do? Thanks 回答1: Since you are using a SqlDataSource then you can get a DataTable out of it like this: var dv = new DataView(); var dt = new DataTable(); dv = (DataView)mySQLDataSource.Select(DataSourceSelectArguments.Empty); dt = dv.ToTable(); I wrote a set of extension methods to do DataTable to CSV, which

VS2017 MYSQL SQLDataSource - Object reference not set to an instance of an object

大城市里の小女人 提交于 2019-12-11 07:10:40
问题 So, I am trying to run a query using SQLDataSource on VS with MYSQL, and whatever the query is, I get the same error which is Object reference not set to an instance of an object . The SQLDataSource is already connected to the database, so there is nothing wrong with my connection string. Web.config <?xml version="1.0"?> <configuration> <connectionStrings> <add name="helbotelConnectionString" connectionString="Data Source=localhost;port=3306;Initial Catalog=helbotel;User Id=root;password

Writing a SQLdatasource in code behind in C# to use a code behind value

六眼飞鱼酱① 提交于 2019-12-11 06:59:18
问题 I am trying to populate a data table using the SQL datasource based upon parametrized inputs .The tricky thing is that the value of the parametrized input is available only in the code behind so I am forced to write the SQL datasource in the code behind page How do I go about it ( I am using C# and ASP.Net 4.0) The current code in the asp.net page to create the sql datasource connection is : <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings