sqldatasource

How to sort columns in an ASP.NET GridView if using a custom DataSource?

I can't get my GridView to enable a user to sort a column of data when I'm using a custom SqlDataSource. I have a GridView in which the code in the ASP reference to it in the HTML is minimal: <asp:GridView id="grid" runat="server" AutoGenerateColumns="False" AllowSorting="True"> </asp:GridView> In the code-behind I attach a dynamical...

Error after changing the primary key to from PKID to UserID

I have a ASP.NET/VB that had a GridView to display a list of users from the Users table. I changed the primary key column name in the database from PKID to UserID and updated all the old references to PKID in the declarations and code behind. I also deleted the WebsiteCache folder which held the visual studio cache of the website. When...

Does anyone know a way to "share" a datasource without causing multiple postbacks?

For instance, I have a SqlDataSource that loads a list of items. On my form, I've got 3 dropdown boxes that both should contain that same list of values, and then the user can select a different value for each and save. By hooking up each dropdown list to the same SqlDataSource, the database gets hit three times - one for each object t...

Dynamically built SelectCommand for GridView SqlDataSource in asp.net

I'm working with a GridView that uses a SqlDataSource element that looks like this: <asp:SqlDataSource ID="InventoryDB" runat="server" ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>" SelectCommand="SELECT [Server], [Customer] FROM [Website] WHERE [Owner] = 'someOwner'"> </asp:SqlDataSour...

How do I force SqlDataSource to use varchar parameters?

I'm using a SqlDataSource to populate my GridView, because the two seem to be so tightly coupled together. Since this grid shows results of a search, I have a dynamic sql string being written in my codebehind that references parameters I pass in, such as below: sdsResults.SelectParameters.Add("CodeID", TypeCode.String, strCodeID) My p...

Upload Image to Database From DetailsView Insert Mode

I am attempting to upload an image to a database via a DetailsView containing an UploadFile control in the Edit Item template. I have a stored procedure which handles the upload to a SQLServer DB which expects two parameters: AuthorName, varchar(20) and AuthorImage, varbin(20). The DetailsView is associated with a SQLDataSource: Author...

SQLDataSource Control DataSourceMode

This is from the book "The ASP.NET 2.0 Anthology" In a discussion in Chapter 3 on the SQLDataSource Control this suggestion is made For simple binding scenarios, however, it's a good practice to switch your DataSourceMode from DataSet to DataReader. but never states why. Does anyone know? Is is faster? ...

How to connect mysql to DevExpress ASPxScheduler without SqlDataSource

I have an ASP.net project I'm looking at and they want to use MySQL. I'm used to SQL server but using mySQL shouldn't be a problem. Normally the control would like a SqlDataSource to bind to but that's not available with MySQL (from other posts on this site). What's the best way to connect MySQL and the DevExpress ASPxScheduler so tha...

IIS 5.1/6.0 Differences with DataGrid and SqlDataSource Refresh

I'm having a strange problem here... I have an ASP.NET 3.5 application that has a GridView and a SqlDataSource on the Default.aspx. The GridView is databound to the SqlDataSource. The GridView has a button for each row called "View" that sends the user to a separate page where the row can be edited. I have two installations of this a...

How to pass variable to SelectCommand of SqlDataSource?

I want to pass variable from the code behind to SelectCommand of SqlDataSource? I dont want to use built-in parameter types (like ControlParemeter, QueryStringParameter, etc) I need to pass a vraiable? the following example does not work <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionSt...

Inject record in SqlDataSource

Hello, I would like suggestions on how to inject a record into my DropdownList to give an "All" option. Here is my code, data coming from the Northwind database. <asp:DropDownList ID="ddlRegion" runat="server" DataSourceID="SqlDataSource1" DataTextField="RegionDescription" DataValueField="RegionID" AutoPostBack="True" ons...

How to add Item to SqlDataSource databound list

I am lazy - and I am using a SQLDataSource to populate my dropdownLists. The Databind event for the databound objects is called before the Page.PreRender so I am doing something like this in the PreRender eventHandler: private void InitializeDropDown() { this.myDropDown.Items.Insert(0, new ListItem("-- Select someth...

asp.net - sqldatasource - detailsview - use stored proc to insert record

I am trying to use stored proc to insert record using detailsview and sqldatasource. I get the following error: Procedure or function 'CustRec_iu' expects parameter '@firstname', which was not supplied. My detailsview definition is as follows: <asp:DetailsView ID="dvCustDetails1" runat="server" AutoGenerateRows="False" DataSource...

asp.net sqldatasource detailview: how to set proper select statement

My page load event looks like this.... SqlDataSource1.ConnectionString = Connection.ConnectionStr; SqlDataSource1.SelectCommand = "select firstname,lastname from customer"; SqlDataSource1.InsertCommand = "CustRec_iu"; SqlDataSource1.InsertCommandType = SqlDataSourceCommandType.StoredProcedure; SqlDataSource1.Inse...

detailsview: insert / update single record

I want to implement the following scenario... Table related to this question is as follows: ProfileID int (identity) FirstName varchar(100) LastName varchar(100) step 1. User visits profiles.aspx page. Here in a grid view, he can see other people profiles. (I know how to do this.) Step 2. User visits MyProfile.aspx page. Since his ...

detailsview: automatic invoke insert or edit mode...

Table structure is as follows: id int identity firstname varchar(100) lastname varchar(100) I have an detailsview control that displays/inserts/updates firstname lastname on profile.aspx page. If customer lands on this page with id in querystring then I want it to load that record into detailsview via sqldatasource and have edit bu...

SQLDatasource CommandTimeout not working

Good day, I'm using a SQLDataSource with a dynamic query generated c#, based on user choices in many fields. However, since our tables are very large, sometimes, I get a command timeout exception. I tried to set the property in 'Selecting' of the SqlDataSource like so: protected void SqlDataSource_PSearch_Selecting(object sender, Sq...

Tips on speeding up a SqlDataSource?

I have two SqlDataSource controls on a page. One loads high level data and the other loads more details based on which high level item you choose. It is a part of a large search that has over 900,000 records and I am looking for ways to speed it up. Whether it is options I can add onto the SqlDataSource, things I can do to the sql que...

SqlDataSource SelectCommand using LIKE does not work

I have the following T-SQL in a SelectCommand: SELECT h.Business, hrl.frn FROM registration hrl INNER JOIN holder h on h.call = hrl.call WHERE (h.Business like '%' + @business + '%' and h.Business is not null) and (hrl.frn = @frn and hrl.frn is not null) business and frn are tied to control parameters and it should return data even...

Can I get the query that was executed from the SqlDataSource?

I have a sql query for my SelectCommand on my SqlDataSource. It looks like the following: SELECT * FROM Books WHERE BookID = @BookID A TextBox feeds the @BookID parameter using an Asp:ControlParameter. When I view the SelectCommand when stepping through the code, I see this: SELECT * FROM Books WHERE BookID = @BookID What I want ...