473,473 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SqlDataSource not binding

I'm having a problem with the new ASP.NET 2.0 SqlDataSource object.
(my first time using it)

I placed a SqlDataSouce object on the page and set its connection
properties in the Web.Config. Using the "Configure Datasource..."
wizard, I can browse my tables and stored procedures fine. If I click
on the "..." button in the select property, I can also browse and
configure my select statement.

The page is a simple lookup page, where the user enters the parameter
values for a stored procedure. The stored procedure is called and
returns a recordset, which is displayed with a repeater object.

My search button click event calls Databind on the repeater object. I
have wired the Selecting event of the datasource to modify some of the
parameters of the command object in the datasource. The code that
follows does execute:

protected void dsIDData_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
if (this.txtTimeclock.Text != string.Empty)
{
e.Command.Parameters["@TimeclockID"].Value =
this.txtTimeclock.Text;
e.Command.Parameters["@EmployeeNbr"].Value = DBNull.Value;
}
else
{
e.Command.Parameters["@TimeclockID"].Value = DBNull.Value;
e.Command.Parameters["@EmployeeNbr"].Value =
this.txtEmpName.Text;
}
}

However, if I use the SQL Profiler (SQL 2000), I never see the server
actually run the stored procedure. As a test, I also wired in the
Selected event from the Datasource object, and it is never called.

I've look at this from every angle. Am I missing something?

Thanks for any help you can give me.
Mike

Feb 2 '06 #1
3 2407
Hi,
I think you must explicitly call the Select() method of your SqlDataSource
object before binding your repeater control.
--
_________________________
Kostas Pantos [MCP]
http://kostas.pantos.name
"Mike T" wrote:
I'm having a problem with the new ASP.NET 2.0 SqlDataSource object.
(my first time using it)

I placed a SqlDataSouce object on the page and set its connection
properties in the Web.Config. Using the "Configure Datasource..."
wizard, I can browse my tables and stored procedures fine. If I click
on the "..." button in the select property, I can also browse and
configure my select statement.

The page is a simple lookup page, where the user enters the parameter
values for a stored procedure. The stored procedure is called and
returns a recordset, which is displayed with a repeater object.

My search button click event calls Databind on the repeater object. I
have wired the Selecting event of the datasource to modify some of the
parameters of the command object in the datasource. The code that
follows does execute:

protected void dsIDData_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
if (this.txtTimeclock.Text != string.Empty)
{
e.Command.Parameters["@TimeclockID"].Value =
this.txtTimeclock.Text;
e.Command.Parameters["@EmployeeNbr"].Value = DBNull.Value;
}
else
{
e.Command.Parameters["@TimeclockID"].Value = DBNull.Value;
e.Command.Parameters["@EmployeeNbr"].Value =
this.txtEmpName.Text;
}
}

However, if I use the SQL Profiler (SQL 2000), I never see the server
actually run the stored procedure. As a test, I also wired in the
Selected event from the Datasource object, and it is never called.

I've look at this from every angle. Am I missing something?

Thanks for any help you can give me.
Mike

Feb 2 '06 #2
Thanks for your response.

I thought of this and tried it. It didn't work.

I think the DataBind method would call the Select method.

Mike

Feb 2 '06 #3
Problem solved !

It appears that there is a property on the SqlDataSource called
"CancelSelectOnNullParameter". This was set to "True", which was
causing my stored procedure call to be cancelled. My stored procedure
had parameters that could be null.

Mike

Feb 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
3
by: adam222 | last post by:
hello, i have a web-form with a GridView control, i wanted to update & delete, using the AutoGenerateEditButton. when i used it with sqlDataSource (executing SP in the DB) it works like a...
0
by: Giovanni | last post by:
I was wondering if someone would be able to help me with the following: Simply put, I have built an ASP.NET 2.0 WebUserControl (UC1). UC1 contains: A GridView which is bound to an SQLDataSource...
0
by: Nam | last post by:
I want to use the same sqlDataSource for two CheckBoxList controls in ASP.NET 2.0. For simplicity, I am using the case of only two CheckBoxList controls in the following example: My...
0
by: rb | last post by:
I'm struggling with (probably) basic things using SqlDataSource and DataList. Here's the problem: I need to read the resultset returned by SqlDataSource to perform actions related to visual...
1
by: gabe | last post by:
Hi, I have 2 scenarios. (1) works, but (2) doesn't ------------------------------------------------------------ 1) I have sqldatasource control using OracleClient. I'm setting the attributes...
6
by: djc | last post by:
I had previously (in asp.net 1.1 and asp.net web matrix) just done this to populate a listbox with data from a database: ------------ this was from the page load event ---------------- 'fill...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hi, I want to create a mailto link from data coming from an SQLDataSource. How do I have to change the following code to get it working? The mailto works, outlook starts with a new message, but...
2
by: LVP | last post by:
Hi, I have a sqldatasource01 configured properly and can databind it to a CheckBoxList and see data with no problem. How can I get the data programmatically from the sqldatasource01 I need to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.