sqldatasource

Accessing data from my SqlDataSource in the code behind C# .net

I have a contact page where there is a datalist of people and if you click on one of them you get a contact form that I want to send to that particular person. I use sqldatasource dscontactemail to get information about that person to place on the contact form but how do I get information out of dscontactemail from the code behind for w...

asp:SqlDataSource binded to asp:DropDownList

I have a asp:SqlDataSource and asp:DropDownList components on my page. On normal page it works ok. Now I'd like to put this on new page with url like ...mypage.aspx?transactionID=2. In Page_Load I would like to set Transaction drop down selected index to 2. But it always binds to 1. I assume, that things happen in this order: in Page_Lo...

Must declare the scalar variable "@Ad1" error in VS2005 and ASP.net

I am using ASP.net 3.5 and i am getting this error. Must declare the scalar variable "@Ad1". What am i doing wrong? My Submit button Protected Sub btnUpdate_Click Try AddressSRC.Update() lblResult.Visible = True Catch ex As Exception lblResult.Visible = True lblResult.Text = ex.Message ...

Set button to disabled when AccessDataSource has no rows

I am using an AccessDataSource control bound to a DetailsView control. When the select returns no rows (the DetailsView disappears, but is still set to visible), then I would like to disable some further functionality by disabling a button. In the C# code behind, I know I will need: ButtonMyButton.enabled = false; However, I am unce...

execute sqldatasource with button

I have two queries that I want to be able to run on a page. I have a button, gridview and sqldatasource at the top of the page and another button, gridview and sqldatasource with the second query at the bottom. How do I associate the buttons with their particular grid and datasource. right now when I click either button, both gridview...

SqlDataSource set SelectCommand dynamicly

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...

How can I do a cast in a SqlDataSource FilterExpression?

I'm using a single textbox to search a report and filter out records. One of my fields is an int32 and the rest are varchar's. So when the filter tries to compare the string from the textbox with the int32 field, I get an error. Here's the SQLDataSouce and the search box: <asp:TextBox ID="SearchBox" AutoPostBack="true" OnTextChanged="Se...

If DataBind() is called inside Page_Load(), then SqlDataSource doesn’t perform updates

If I bind GridView (via DataSourceID attribute) to SqlDataSource and set SelectCommand and UpdateCommand attributes, then everything works perfectly. But I’ve noticed that if I, for whatever reason, also manually call DataBind() inside Page_Load(), then SqlDataSource doesn’t perform any updates, even though SqlDataSource.Updating and S...

Do not fill DropDownList if upstanding UserControl isn't visible

I have page Add.aspx containing a number of UserControls: AddRequest.ascx, AddOperation.ascx, AddObject.ascx, etc. Depending on Request["type"] one control becomes visible. Each UserControl contains a number of DropDownLists that are being filled via SqlDataSource from DB. For example, types, statuses, currencies, etc. It seems that ap...

Delete User from Table and ASPNET Membership Provider with sqlDataSource

I have a Gridview that shows a list of Contacts via a sqlDataSource. Included is an Item Template for Deleting a record - a LinkButton - with OnClientClick set to use some JavaScript: "return confirm('Are you sure you want to delete this user?');" This give the user a little pop up with a Yes or Cancel option. When the user is del...

Using Data Source configuration wizard vs manually configuring data source

Hi all, Back in the days of VB 4 / VB 5, using data bound controls and data connection wizards would add alot of overhead to the application. I wanted to know if using the "Configure Data Source" wizard in ASP.Net 3.5 adds alot of unneeded overhead to the webpage? Thanks ...

Query Works in sqlDataSourceControl but not at Runtime

I have a query that works when I test it in the sqlDataSource control (wizard test button) but it doesn't work when I run the page. I made sure the gridview has the correct sqlDataSource control as its source. This is driving me crazy. Has this happened to anyone else? edit: It has something to do with this line in the where clause ...

sqldatasource problem

I have a query that works when I test it in the sqlDataSource control (wizard test button) but it doesn't work when I run the page. I made sure the gridview has the correct sqlDataSource control as its source. This is driving me crazy. Has this happened to anyone else? edit: It has something to do with this line in the where clause (i...

how to edit my connection string to work with System.Data.SqlClient?

Hi, i am a newbie programmer, and i have a problem with sqldatasource. In my project, i have a database called "KFS". I have a gridview and sqldatasource as gridview's datasource. I have a connection string like that: "KFSConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=KFS;Integrated Security=True" provi...

SqlDataSource Connection String from .aspx page

Hi, I have a solution for ASP.NET pages to be deployed to SharePoint that uses SqlDataSources on a few of the pages. Since with the SharePoint deployment the web.config file that is associated with our application (deployed to GAC) is the web.config for the SharePoint server, we do not have full access for all environments to change the...

Can we configure data source control to first perform update and only then select operation (when DataBind() is called manually)?

Hello, If we set GridView’s DataSourceID to SqlDataSource/ObjectDataSource and manually call GridView.DataBind(), then the select operation is performed first and then the update operation. But since select operation automatically resets edited values, data source doesn’t get updated, even though Updating and Updated events do fire. ...

How do I default all my SqlDataSource parameters to convert empty string to null?

I have a project that utilizes a number of FormViews and SQLDataSources. I would like the default behavior of the SQLDataSource to insert values that are empty as null. I know I can do this by creating an insert parameter for each parameter, but this gets really old for having to do this for update and insert on every parameter that co...

ASP.NET Gridview Updating Capabilities

The Gridview control in ASP.NET provides updating capabilities when assigning a SqlDataSource control to the Gridview's DataSourceID, however when programmatically assigning a code level SqlDataSource to DataSource, the built-in updating capabilities go away and you are forced to roll your own. Why? What is the difference here, since all...

SqlDataSource Timeout. OK in Management Studio

In code that I inherited, I have a SqlDataSource that has a fairly complex select statement that for certain SelectParameters, always times out ("Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."). When I run the exact same query with the same parameters in management stu...

Sql Equivalent to UInt16

I know that the Sql equivalent of Int16 is SqlInt16. But what is the Sql equivalent of UInt16, UInt32 and Uint64? ...