SqlDataSource not binding

M

Mike T

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
 
G

Guest

Hi,
I think you must explicitly call the Select() method of your SqlDataSource
object before binding your repeater control.
 
M

Mike T

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
 
M

Mike T

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top