The SqlDataSource control enables you to use a Web control to access data located in a relational database, including Microsoft SQL Server and Oracle databases. The SqlDataSource control uses ADO.NET classes to interact with any database supported by ADO.NET. You can use the SqlDataSource control with other controls that display data, such as the GridView, FormView and DetailsView controls to display and manipulate data using little or no code.
Questions tagged [sqldatasource]
967 questions
4
votes
2 answers
Gridview is not displayed when using stored procedure in SQLDatasource
I stumbled across this before and I know it is a common problem. One related question is GridView is empty. But it does not solve my problem.
Ideally what I want is update my gridview depending on the value in a textbox when I click the 'Find'…

TheTechGuy
- 16,560
- 16
- 115
- 136
4
votes
5 answers
How to handle exceptions with a SqlDataSource
I have a SqlDataSource that is supplying data to my GridView. Thats all i am using on my form, thus i have NO code behind at all. But somewhere i need a TRY CATCH block just in case my connection get's lost. What code must i place where?
If i get a…

Etienne
- 7,141
- 42
- 108
- 160
4
votes
2 answers
How to sanitize a query string when used with a databound repeater control?
Given the following URL:
domain.com/page.aspx?id=123
How can I sanitize that query string value when it is used on a Databound Control such as a repeaters SqlDataSource?

Michael Jasper
- 7,962
- 4
- 40
- 60
4
votes
2 answers
Why won't my UpdatePanel update my Listbox as I expect on button click?
I have a form with a dropdownlist, two buttons, and two Listboxes inside an UpdatePanel. The Dropdownlist, and listboxes are all bound to SqlDatasources. The dropdownlist allows you to choose your department.
The first listbox shows a list of Jobs…

Lucretius
- 1,053
- 1
- 13
- 26
4
votes
2 answers
Skip setting value of sql parameter in SqlDataSource in WebForm
I am making a WebForm in asp.net and I want to display gridview with data from asp:SqlDataSource
My problem becomes when I try to skip (pass null) values for some of the Parameters.
Here is some snippets of my code
In aspx file sqldatasource looks…

adopilot
- 4,340
- 12
- 65
- 92
4
votes
2 answers
SQLDatasource parameters
How can i set sql parameters for an sqlDatasource in the code behind?
I am trying like this:
int id=1;
SqlDataSource1.SelectCommand = "SELECT * FROM categ WHERE id=@id";
SqlDataSourceArticole.SelectParameters.Add("@id", id);
// and also like…

hhh3112
- 2,167
- 10
- 36
- 55
4
votes
1 answer
Why does my DbProviderFactory perform differently than SqlClientFactory?
I implemented a custom DbProviderFactory which returned the SqlX types except I added the following logic to CreateCommand
public override DbCommand CreateCommand()
{
var cmd = new SqlCommand();
if (CommandCreated != null)
…

Arrya Regan
- 1,104
- 8
- 22
4
votes
2 answers
Changing SqlDataSource.SelectCommand at runtime breaks pagination
I have a GridView bound to a SqlDataSource with a default SelectCommand defined as such:

Mark Richman
- 28,948
- 25
- 99
- 159
4
votes
2 answers
ASP.NET Setting parameter for SqlDataSource programatically does not work for postback
I want to set a parameter for a SqlDataSource programmatically as described in Step 5 at http://www.asp.net/data-access/tutorials/using-parameterized-queries-with-the-sqldatasource-vb . Also a GridView is bound to the sqlDataSource. My markup…

harrije
- 407
- 4
- 12
- 21
4
votes
1 answer
SqlDataSource_OnSelected: Get data (DataTable) without re-executing the query
I have a SqlDataSource bound to a GridView with an SQL that takes about 10 seconds to retreive the data.
Also there is a UserControl called "PageSizeControl" which hooks the selected-event of the GridView's SqlDataSource. In this event, I need the…

Vortex852456
- 721
- 6
- 23
4
votes
3 answers
Use of SqlDataSource From Non-Control Situations
As part of my common utilities I used in all my line of business applications, I have this code...
using System.Web.UI.WebControls;
public class Database
{
///
/// Creates a DataView object using the provided query and an…

mason
- 31,774
- 10
- 77
- 121
4
votes
2 answers
Using a dropdownlist control inside a formview
I am new to asp.net and i have a problem using a dropdownlist control inside a formview and passing its value to the related sqldatasource. When i use the code below i get the following exception
Exception Details: System.InvalidOperationException:…

rematnarab
- 1,277
- 4
- 22
- 42
4
votes
2 answers
SqlDataSource Insert code behind variable
I have the following SqlDataSource

Jorg Ancrath
- 1,447
- 10
- 34
- 61
4
votes
4 answers
How to pass property value in SqlDataSource selectCommand where conditon?
I have a property in my page2.aspx.cs page
public int? Id
{
get
{
if (ViewState[Page1.Id] != null)
return Convert.ToInt32(ViewState[Page1.Id]);
else return null;
}
set
…

Rocky
- 4,454
- 14
- 64
- 119
3
votes
5 answers
Change select command of sqldatasource at runtime
HTML

user1263390
- 187
- 3
- 4
- 12