sqldatasource

sqldatasource insert return identity value

Im using SqlDataSource sds = new SqlDataSource(); in code behind and inserting using sds.Insert(); Please tell me how to get inserted record primary key value? Please note im not using stored procedure. ...

ASP.NET Declaritive Data Sources. Are they ever used if more than one table is invovled?

For typical examples I see of SqlDataSource, LinqDataSource... EVERY example deal with how to make changes to a Customer table where the Gridview/RADgrid directly represents the customer.. But in my case I have stored procedure which show data from multiple tables and make changes to multiple tables so it seems I am not a canidate for ...

How to use User.Identity.Name as a parameter for SqlDataSource in ASP.NET?

For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source. I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is...

writing audit records of pre and post values

I'm currently using an SqlDataSource in ASP.NET/C# to let users insert, delete and update entries in a table/gridview. Every event needs to be written to an audit table. I have easily implemented inserting and deleting - when inserting, the main info audited is just the parameter values of the insert query (e.Command.Parameters[0].Value...

Returning PK of gridview when updating or inserting (ASP.NET, C#)

I require all changes such as inserts, updates and deletes to a table to be auditted, and I'm using a simple SQLDataSource and GridView with automagically generated INSERT/UPDATE/DELETE statements. Problem is, when a row is updated I want to get the ID (primary key) and put that into the auditting table - but because the only parameters ...

What's wrong with my IF statement?

I'm creating an auditting table, and I have the easy Insert and Delete auditting methods done. I'm a bit stuck on the Update method - I need to be able to get the current values in the database, the new values in the query parameters, and compare the two so I can input the old values and changed values into a table in the database. Here...

Accessing rows PK after Insert (SqlDataSource)

I need to be able to get the primary key of an nserted row in C#, and so far I'm unsure how. I've put SELECT SCOPE_IDENTITY() into my SQL query, but how do I access this from the SqlDataSource_Inserting method, so I can store it in an auditing table? In my method I only now how to access the parameters (e.Command.Parameters) EDIT: My p...

How to display elements only if SQLDataSource has rows

Hi all, I'm creating an ASP.NET/C# page where a user enters an ID at the top of the page, and when they press Submit, the page posts back and displays the data. Right now, the data fields are displayed at all times - even when the page loads and no search has taken place. This is not ideal as when they navigate a Menu with a MultiView I ...

SqlDataSource1_Selected not working

Hi, I need to be able to change a Boolean variable if a datasource actually retrieves any data, so gridviews/detailsviews aren't displayed. I've placed all the data inside a PlaceHolder tag which is by default not visible. But using the SqlDataSource1_Selected method, it doesn't actually change the boolean variable - why is this? Here i...

Hiding/disabling ASP.NET controls when SqlDataSource is empty

Hi, I need to be able to hide or disable a multitude of items (detailsviews, gridviews) when an SqlDataSource returns no rows. So if the page is reposted and no rows are selected, all the controls would be disabled. How would I do this? Thanks ...

Filter expression not working correctly

Hi, I am using a GridView and I require the user to be able to filter using 2 controls. One simply filters the type of row - there is a column called action, and the user selects one of the distinct values from the database in a dropdown box, and the gridview only displays the rows with that value in the action column. On it's own this w...

Ways to detect changed account/no account found in ASP.NET/C#

I have an ASP.NET page where at the top of the page is a search box. There are 2 text boxes - one is an autocomplete extender for the Name on a database, and one is just inputting the ID. The page features DetailsViews and GridViews primarily, and even when no account has been searched for, these display blank data which is not ideal. I...

gridview filtering via joined tables

I'm trying to display data which comes from a join on two tables (or more) in a gridview I want to be able to filter the result set via user given input (text boxes on page) I have tried the standard tutorials but cannot find something which goes beyond displaying one table result sets in the gridview. If I go through the configure gr...

passing querystring

Consider a page, when the page loads, nothing shows up. It works when i pass the querystring on the browser as this: http://localhost:51765/foo/foo.aspx?ID=c516f4f4-36a9-40a7-baad-d2419ea631b9 I want it to work when the page load not when i pass the querystring on the browser. Can someone help me with this? <asp:SqlDataSource I...

Problem with ASP Repeater and SQL Data Source

Hi! Here's my data table in my SQL DB, and below that is the code for my Repeater control: ArticleID int NOT NULL, ArticleTitle varchar(100) NOT NULL, ArticleCategory int NOT NULL, ArticleDate datetime NOT NULL, ArticleContent text NOT NULL, DeletedYN char(3) NOT NULL <asp:Repeater runat="server" ID="rptArticles" DataSourceID="dsLates...

Problems passing properties into UserControl Asp.Net

I'm trying to create a UserControl in ASP.NET to display news items based on two values that are passed in, NewsTag and ItemLimit. The problem is that the SQLdatasource is not picking up the properties in SqlDataSource1_Init. Instead the calls to the properties are empty when this is called but after render have values. <script runat="s...

Which event to add programmatic parameter to sqldatasource in asp.net vb

I am trying to add a selectparameter to my sqldatasource (SqlDS) using this code: SqlDS.SelectParameters.Add(New Parameter("@approver", Data.DbType.String, "approved")) The error I keep getting is System.Data.SqlClient.SqlException: Must declare the variable '@approver'. Is there a specific event I need to use this code within? Than...

How to programmatically iterate through pages of a GridView

Hi all. I've created a wallboard application to display outstanding support calls for my ICT department. I've bound a number of gridviews to sqldatasources which execute a stored procedure. This is automated via asp.net ajax controls and partially refreshes the page/data every 30 seconds. At the moment, when the number of records in t...

Rebind gridview using AJAX (without post back)

Hi, I plan on allowing a user to open a modalpopupextender containing a gridview witha Filter text box. I want it so when the user types in a filter, the filter is applied to the gridview and the contents of the gridview is then updated to reflect the applied filter - all without posting back. Also ideally the gridview will be filtered a...