Sqldatasource, Does It Select If Not Bound To A Gridview, Formview On The Page?
Using 3.5
If I have a sqldatasource on the page, is it run if it is not bound to a data object like a gridview?
Seems like if i want to access the data (like set a label text) from the sqldatasource I have to use code to first create a dataview then pick throught it. This seems like I'm running it twice. I'm new at .net so I dont know how to tell.
I don't want to write data select code programatically when I can just through an SDS on the page, but wondered it it ran just because it's on the page.
View Complete Forum Thread with Replies
Related Forum Messages:
-
Removing Rows From A SqlDataSource Before It Is Bound To A GridView?
-
Changing The SQLDatasource SELECT For A Gridview
-
How Do I Populate A Formview From Multiple Columns In A Gridview
-
Get Value From SqlDataSource1 Bound To Gridview
-
Issue Inserting Null Value Into A Formview/gridview Control
-
Paging A Gridview Bound By A Sqldatareader?
-
Access All Records From Bound GridView Control
-
FormView W/SqlDataSource - Auto Disposed?
-
Sqldatasource And Formview Insert Problem
-
Retrieve Data From SqlDataSource Or FormView
-
SqlDataSource Outside Of FormView Container Cannot See Controls!
-
Retrieving Values From Stored Procedure Using FormView && SqlDataSource
-
SqlDataSource With Different Number Of Columns And Insert Parameters And FormView
- How Can You Place A Data Bound Footer In SSRS On Every Page?
-
Gridview And Sqldatasource
-
GridView - SqlDataSource
-
SqlDataSource, GridView && A Button
-
Profile, SQLDataSource And GridView
-
Question About Gridview And SqlDataSource
-
&<asp:SqlDataSource&> Generate SQL For GridView?
-
Can You Have A FormView Use SELECT FROM WHERE IN?
- How To Get A Data Bound Page Footer In SSRS In A Report Having Multiple Tables?
-
An SQLDataSource On 2 Other DataSources? Show In A GridView
-
GridView && SqlDataSource Delete Problem
-
Gridview Updated + SQLDatasource + UserName
-
Number Of Records In SQLDataSource/GridView
-
GridView Using Sqldatasource Stored Procedure
-
GridView Via SQLDataSource And Stored Procedure
-
Binding A SqlDataSource, To A GridView At Runtime
- SqlDataSource Not Updating On Editing GridView
-
Qestion About SQLDataSource, Gridview, And Update Panel
-
Binding A Gridview To Sqldatasource On Button Click
-
Sqldatasource How To Not Load The Gridview With The SqldataSoruce At Page_load C#
-
SqlDataSource + GridView - Scalar Variables Not Being Read
-
Change Dynamically(via Code) The SqlDataSource For A GridView....
-
Problem Encountered With Filterparameter On SQLDataSource For GridView
-
GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)
-
Why Can't I Enable Editing On A Gridview That Gets It's Data From A View Through An SqlDataSource?
-
Gridview Button For Calling Sqldatasource.update Fails
-
Performance Comparison - Code Vs SqlDataSource, Gridview Etc Vs PlainControl
-
Problem To Retrieve Data With Help Of SP And Sqldatasource,gridview,controls
-
Prevent Loading Sqldatasource And Populating Gridview On Pageload
-
Retrieving Selected Gridview Column Values For SQLDatasource Asp:controlparameters
- Showing GridView In PDF Format When Page Loads!!!
-
Gridview - SqlDatasource - How Do You Get All Values For A Like Text Parameter Or A Boolean Field When Filtering?
-
Issue With Getting Values From Child Controls In A Gridview, To Use For The Update Using A SQLDataSource Control
-
Stored Procedure Passes Test In Gridview, But Nothing Shows Up On The Page
-
SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource
-
Gridview Select
-
SQLDataSource Cntrl - FormView Cntrl - UPD Sproc And Sproc Debugger. I Dare Anyone To Figure This One Out.
-
Select Parameters With Gridview
-
Gridview / SqlDataSource Error - Procedure Or Function &<stored Procedure Name&> Has Too Many Arguments Specified.
Changing The SQLDatasource SELECT For A Gridview
I cant seen to change the Select command for a SQL Datasourcetry #1 SqlDataSourceProfilesThatMatch.SelectCommand = strSQLForSearch SqlDataSourceProfilesThatMatch.SelectParameters("ProfileID").DefaultValue = pProfileID SqlDataSourceProfilesThatMatch.SelectParameters("LoggedInUsersZipcode").DefaultValue = pUsersZipCode SqlDataSourceProfilesThatMatch.SelectParameters("ZipDistance").DefaultValue = pDistance NewProfilesThatMatchGridView.DataBind() try #2 SqlDataSourceProfilesToBeMatched.SelectParameters.Clear() SqlDataSourceProfilesThatMatch.SelectCommand = strSQLForSearch SqlDataSourceProfilesThatMatch.SelectParameters.Add("ProfileID", pProfileID) SqlDataSourceProfilesThatMatch.SelectParameters.Add("LoggedInUsersZipcode", pUsersZipCode) SqlDataSourceProfilesThatMatch.SelectParameters.Add("ZipDistance", pDistance) NewProfilesThatMatchGridView.DataBind() No errors but no rows show in the gridview. If I debug and get the value strSQLForSearch and paste it into a new SQL query window I get results. Any ideas???? Thanks
View Replies !
How Do I Populate A Formview From Multiple Columns In A Gridview
Hi, I have a master/detail scenario whereby to populate a formview, the user selects a row in the gridview. The SqlDataSource used to populate the formview needs to check 2 columns from the gridview, ZRef (which is the SelectedValue of the Gridview) and ZName (a string). From searching the forums it looks like I have to programmatically assign the SelectParameters in order to get ZName from the gridview. Seems fair enough, so I set the parameters in the 'Selecting' event of the SqlDataSource. (Code shown below). However the formview never shows. In debug I can see that the values I'm setting in the SelectParameters.Add are correct; and if I set the default values for those parameters in the SqlDataSource itself, everything works fine. Can anyone point me to some sample VB code that does this - I'm sure this must be a common situation. Thanks. Protected Sub sdsOff_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Dim tmpSDS As SqlDataSource Dim tmpLBL As Label tmpSDS = CType(FormView1.FindControl("sdsOff"), SqlDataSource) If tmpSDS Is Nothing Then Server.Transfer("ErrorOnPage.htm") End If tmpLBL = Me.GridView1.Rows(GridView1.SelectedIndex).FindControl("lblName") If tmpLBL Is Nothing Then Server.Transfer("ErrorOnPage.htm") End If tmpSDS.SelectParameters.Clear() tmpSDS.SelectParameters.Add("ZRef", GridView1.SelectedValue) 'In debug, this shows 7 - which is correct tmpSDS.SelectParameters.Add("ZName", tmpLBL.Text) 'In debug, this shows 'Fred Bloggs' - which is correct End Sub
View Replies !
Get Value From SqlDataSource1 Bound To Gridview
Hi, I have a gridview that is bound to my SQL data source. In my select command, I am pulling back 5 columns, and only binding 4 of them to the grid. One of the columns displayed is a filename, and the column that is pulled back but not bound is a byte array or "image" datatype that contains the actual file. I have the file name as a link button so when you click it, I want to retrieve the file from the datasource so I can stream it out to the browser. However I can't find how to access the actual data rows in the datasource as it doesn't seem to act like a typical dataset/datatable. Any suggestions on how to do this? TIA
View Replies !
Issue Inserting Null Value Into A Formview/gridview Control
Hi, My formview or gridview control stops updating or deleting a record once the record has a null value. I have table tblTest with the following pkID int NOT NULL **IDENTITY COLUMN** string1 varchar(30) string2 varchar(30) I then create a SqlDataSource with the statement: Select * From [tblTest] I have the insert, update and delete statements generated, and choose optimistic concurrency. I add a couple records of dummy data. I then drag a Formview control onto the page, and bind it to the SqlDataSource I just created. I then fire it up in my browser, and I can then update, insert and delete records. However, as soon as I update a record with a null value, I can no longer update or delete that record. So, if I had a record in my FormView like: string1: foo string2: bar I can update and delete normally. And when I update to: string1: foo string2: the database correctly inserts a null value into string2. However, once that null is in the record, I can't change anything about the record. If I try to delete the record, the FormView will then display the previous record, but I can still page to the record that should have been deleted, and it still exists in the db. If I try to update the record, the edits I make will not keep and the process will fail silently. What am I doing wrong? Should i be binding to a different object? Regards, Chris
View Replies !
Paging A Gridview Bound By A Sqldatareader?
Basically what I have is a library search, the user enters a keyword and selects the library location closest to him, and the search topic (author, title, etc), from there the press search and it displays all teh results in one gridvew. I have a switch statment that determins what sql query is executed by the sqldatareader. I then bind the gridview to the sqldatareader. Now, Im having the darndest time binding this.
View Replies !
Access All Records From Bound GridView Control
I am using the Visual Web Developer Express, C#.I have a query that is bound to a GridView object with record paging enabled.For purposes of displaying a map, I need the ability to loop through the paged record set (just the 10 current records) and send the address, city, state, and zipcode to a function. Using the GridView, I can access any of the records that are visible in the gridview. See code below. for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; count++; _addr = row.Cells[3].Text.ToString(); _city = row.Cells[4].Text.ToString(); _state = row.Cells[5].Text.ToString(); lblMapJS.Text += Get_Map_Point(_addr, _city, _state, count); }Annoyingly, I am unable to access the rest of the fields in the recordset, namely the records that are not being displayed the in the GridView. How can I gain access to all fields, but just the current recordset?
View Replies !
FormView W/SqlDataSource - Auto Disposed?
Hi everyone, I'm in a scenario where I am using a FormView control to edit records. The data access is being done with an associated SqlDataSource control. The pipeline I use is usually setup using this pattern: (1) SqlDataSource.OnInserting -> (2) SqlDataSource.OnInserted -> (3) FormView.OnItemInserted The SqlDataSource events expose a SqlDataSourceCommandEventArg parameter that is much like a DbCommand object where you can start a transaction and associate other command objects with the command flowing through the pipeline. My question is does asp.net automatically dispose of the SqlDataSourceCommandEventArg command or must I do it manually? I assumed that after the SqlDataSource.OnInserted event the object would be disposed. If anyone has articles on this or any insight would be appreciated. Thanks
View Replies !
Sqldatasource And Formview Insert Problem
I m trying to INSERT a record to my Consultants table using sqldatasource and formview: here is my sqldatasource code: <asp:SqlDataSource ID="sqlDS1" runat="server" ConnectionString="<%$ ConnectionStrings:myDB %>"InsertCommand="INSERT INTO [Consultants] ([firstName],[lastName],[skillCategoryID],[resourceManagerID],[AMgroupID],[skillSet],[statusID],[location],[comments],[profile],[isAvailable],[dateModified],[focusID]) VALUES (@FNAME, @LASTNAME, 1, @RESOURCEMANAGERID, @AMGROUPID, @SKILLSET, @STATUSID, @LOCATION,@COMMENTS,@PROFILE,@ISAVAILABLE,getdate(),1)"> <InsertParameters> <asp:FormParameter FormField="txtFName" Name="FNAME" /> <%--other parameters--%></InsertParameters></asp:SqlDataSource> now in my formview i have this:<asp:FormView DefaultMode="Insert" ID="FormView1" runat="server" DataSourceID="sqlDS1" DataKeyNames="id"> <table border="0" cellspacing="5" cellpadding="0"><tr> <td class="blacktextbold">First Name:</td> <td class="blacktext"><asp:TextBox ID="txtFName" CssClass="txtfield" Width="200" runat="server" Text="<% #Bind('firstName')%>" /> <asp:RequiredFieldValidator ControlToValidate="txtFName" runat="server" ValidationGroup="gpInsert" ErrorMessage="Required Field" Display="Dynamic" CssClass="redtextsmallbold" /> </td></tr> </table> THE PROBLEM:no matter what i put the txtFName field its ALWAYS null and i get INSERT error as column firstName cant accept NULLany ideas? ur help would be appreciated
View Replies !
Retrieve Data From SqlDataSource Or FormView
Is it possible to retrieve a single value from the sqlDataSource which contains only one row in the code behind page? and is it possible to retrieve a single value from one of the label inside the formview in the code behind page? I want to use the particular value for programming inside the code behind page using visual studio
View Replies !
SqlDataSource Outside Of FormView Container Cannot See Controls!
I'm not getting any results in the area I posted this message in. Can anyone here help? Original post: I have a DDL within a Formview that is not viewable by the insert statement in a SqlDataSource outside of the Formview. This problem is exactly the same as the following thread: http://forums.asp.net/632568/ShowPost.aspx Unfortunately, placing the SqlDataSource directly above the formview doesn't resolve the issue. Does anyone have any suggestions? I did try "Help", "Check for updates". This failed because I was running FireFox. I uninstalled FireFox hoping this would resolve the problem. I now get an error "Operating Could Not be Completed. Application Not Found". I did try setting the "Browse with" option to IE, but this doesn't fix the problem. The version of VWD 2005 Express I am running is: version 8.0.50727.42 (RTM.050727-4200) Could this be the problem?
View Replies !
Retrieving Values From Stored Procedure Using FormView && SqlDataSource
Please excuse me if this question has been asked before; I couldn’t find it. Perhaps someone could point me to the solution. A few years ago I wrote an order-entry application in classic ASP that I am now re-writing in ASP.NET 2.0. I am having very good success however I can’t figure out how to retrieve data from a stored procedure. I am using the FormView & SqlDataSource controls with a stored procedure to insert items into an order. Every time an item is inserted into the order the stored procedure does all kinds of business logic to figure out if the order qualifies for pricing promotions, free shipping, etc. If something happens that the user needs to know about the stored procedure returns a message with this line (last line in the SP) SELECT @MessageCode AS MessageCode, @MessageText AS MessageText I need to retrieve both the @MessageCode and the @MessageText values in my application. In classic ASP I retrieved these values by executing the SP with a MyRecordset.Open() and accessing them as normal fields in the recordset. In ASP.NET I have specified the SP as the InsertCommand for the SqlDataSource control. I have supplied all the parameters required by my SP and told the SqlDataSource that the insert command is a “StoredProcedure�. Everything actuly works just fine. The items are added to the order and the business logic in the SP works fine. I just have no way of telling the user that something important has happened. Does anyone know how I can pickup these values so that I can show them to my users? Bassicly if @MessageCode <> 0 I want to show @MessageText on the screen.
View Replies !
SqlDataSource With Different Number Of Columns And Insert Parameters And FormView
Dear All, i have a SqlDataSource with a simple select command(e.g. "select a,b,c from foo"). The insert command is a stored procedure and takes less parameters than there are columns in select statement (e.g. "insertFoo(a char(10))"). When used in combination with form view, i get "Procedure or function insertFoo has too many arguments specified" error. It seems that form view always posts all columns as parameter collection (breakpoint in formview_inserting event shows this) to insert command. Am I doing something wrong or is this by design? Is the only solution to manualy tweak parameters in formview_inserting event? TIA Jernej
View Replies !
How Can You Place A Data Bound Footer In SSRS On Every Page?
I am having another setback with a report which has got multiple tables and sections. Here i wanted to have a footer for every page which is databound to a table. now since there are multiple sections and multiple tables...the things have become more complicated. is there any way you could tell me to go around this problem so that i can put a common footer on every page of the reports no matter how many pages it goes on?? Just to put it in points... I need.. to a) Place a databound footer(a footer that is bound to a datasource and not hard coded) into the page footer in SSRS. No matter how long the report is in pages. b) I need it to appear on every page of the report after it is rendered to a PDF. I have placed a textbox in the body of the report and linked it to a textbox in the footer of the report. Now the thing is it is not working. Cud u please tell me diffrent ways or any possible way this could be done.? Plz help.. Regards Savio
View Replies !
Gridview And Sqldatasource
i have a gridview which is bound to sqldatasource. i have a delete button in the gridview. I have written code for "deleting" a record in app_code directory. now iam not using "deletecommand" of sqldatasource but on the click of "delete" link i want to call the procedure in the app_code. Any ideas on how to do it.??
View Replies !
GridView - SqlDataSource
I have created a GridView that uses a SqlDataSource. When I run the page it does not pull back any data. However when I test the query in the SqlDataSource dialog box it pulls back data. Here is my GridView and SqlDataSource: <asp:GridView ID="Results" runat="server" AllowPaging="True" AllowSorting="True" CellPadding="2" EmptyDataText="No records found." AutoGenerateColumns="False" Width="100%" CssClass="tableResults" PageSize="20" DataSourceID="SqlResults" > <Columns> <asp:BoundField DataField="DaCode" HeaderText="Sub-Station" SortExpression="DaCode" > <ItemStyle HorizontalAlign="Center" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="DpInfo" HeaderText="Delivery Point" SortExpression="DpInfo" > <HeaderStyle HorizontalAlign="Left" CssClass="tdHeaderResults" /> <ItemStyle CssClass="tdResults" /> </asp:BoundField> <asp:HyperLinkField DataNavigateUrlFields="CuCode,OrderID" DataNavigateUrlFormatString="TCCustDetail.asp?CuCode={0}&OrderID={1}" DataTextField="OrderID" HeaderText="Order No" SortExpression="OrderID"> <ItemStyle CssClass="tdResults" HorizontalAlign="Center" /> <HeaderStyle CssClass="tdHeaderResults" HorizontalAlign="Center" /> </asp:HyperLinkField> <asp:BoundField HeaderText="Order Date" SortExpression="OrderDate" DataField="OrderDate" > <ItemStyle HorizontalAlign="Center" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="ReqDeliveryDate" HeaderText="Req Delivery Date" SortExpression="ReqDeliveryDate" > <ItemStyle HorizontalAlign="Center" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="StatusDate" HeaderText="Status Date" SortExpression="StatusDate"> <ItemStyle HorizontalAlign="Center" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="ManifestNo" HeaderText="Manifest No" SortExpression="ManifestNo"> <ItemStyle HorizontalAlign="Center" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="CustomerPO" HeaderText="P.O. No" SortExpression="CustomerPO"> <ItemStyle HorizontalAlign="Center" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class"> <ItemStyle HorizontalAlign="Left" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Left" CssClass="tdHeaderResults" /> </asp:BoundField> <asp:BoundField DataField="OrderStatus" HeaderText="Order Status" SortExpression="StatusSort"> <ItemStyle HorizontalAlign="Left" CssClass="tdResults" /> <HeaderStyle HorizontalAlign="Left" CssClass="tdHeaderResults" /> </asp:BoundField> </Columns> <HeaderStyle ForeColor="White" HorizontalAlign="Left" /> <AlternatingRowStyle CssClass="tdResultsAltRowColor" /> </asp:GridView> <asp:SqlDataSource ID="SqlResults" runat="server" ConnectionString="<%$ ConnectionStrings:TransportationConnectionString %>" SelectCommand="GetOrderSummaryResults" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter DefaultValue="10681" Name="CuCode" Type="String" /> <asp:Parameter DefaultValue="" Name="DaCode" Type="String" /> <asp:Parameter DefaultValue="" Name="DpCode" Type="String" /> <asp:Parameter DefaultValue="" Name="OrderID" Type="String" /> <asp:Parameter DefaultValue="" Name="ManifestNo" Type="String" /> <asp:Parameter DefaultValue="" Name="PONo" Type="String" /> </SelectParameters> </asp:SqlDataSource> I can get it to fill with data by manually filling the GridView without using a SqlDataSource but then I cannot get the sorting to work when I do it that way. Actually not sure if the sorting will work this way either as I cannot get it to fill with data. Any ideas would be much appreciated.
View Replies !
SqlDataSource, GridView && A Button
hi .. i have a SqlDataSource, GridView & a Button .. i want to increase the condition in the "SelectCommand" below by one everytime i click the button .. i mean to be like that ID < 8 instead of ID < 7 so, the GridView will show 7 ID's instead of 6 .. and it will increase everytime i hit the button<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connectionstring %>" SelectCommand="SELECT * FROM [table1] WHERE ID < 7"> </asp:SqlDataSource>
View Replies !
Profile, SQLDataSource And GridView
Hello.When I create a user at the ASP.NET database, I need to insert more fields than the defaults, and I do it like this: Dim customProfile As ProfileCommon = ProfileCommon.Create(CreateUserWizard1.UserName, True) customProfile.telephone = (CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("TelephoneText"), TextBox)).Text(telephone example)Those data are inserted at the DB at the aspnet_Profile table, in the fields PropertyNames & PropertyValuesString, but they are saved together (see image above) I want to separate those properties in the GridView as long as each property appears in a column, is it possible? Thank you very much, i'm expecting your answers.
View Replies !
Question About Gridview And SqlDataSource
i am now writing a web page which can allow users to edit the field(display in the gridview->gridview source is from sqldatasource), there is a problem(it seems that i have followed all steps in the book): when the i edit the field and click update, in the web site, i can see those changes. however, i cant see any change in database table. i cant find solution on this, could anyone help me to solve this problem? thx!
View Replies !
&<asp:SqlDataSource&> Generate SQL For GridView?
Hi guys.Im using a gridview to show some training data on my website which is populated by:<asp:SqlDataSource ID="ARENATraining" runat="server" ConnectionString="<%$ ConnectionStrings:ARConnection %>" SelectCommand="SELECT [EventType], [CourseLink], [EventDate], [EventTitle], [EventLocation], [EventWebsite] FROM [qry_FutureEvents] WHERE ([EventPrivate] = @EventPrivate) ORDER BY [EventDate]"> <SelectParameters> <asp:Parameter DefaultValue="FALSE" Name="EventPrivate" Type="Boolean" /> </SelectParameters> So far so good..However I want to be able to filter the data.A) Show everythingB) Show individual EventType i.e. Seminar, Training etc etcIs it possible to generate the Select Command via a function? (im not using stored procedures for this part of the site, nor really want to at the moment). Id appreciate any help, otherwise ill be forced to curse and swear and use the good ol repeater and figureing out how to page it! Cheers guys
View Replies !
Can You Have A FormView Use SELECT FROM WHERE IN?
How can I generate the following command with VB Code Behind in NET 2.0 and have a FormView access the command. The 4 and 20 below may be 3 and 100 and etc."SELECT * FROM [Solution] WHERE ([SolutionID] IN ('4', '20'))" The List is generated by two multiselect controls (ListBox and CheckBoxList) and a text box used to search a description field in VB code behind (ASPX.VB) This post is a summary of a previous post not responded to. Sincerely,Unhistoric
View Replies !
How To Get A Data Bound Page Footer In SSRS In A Report Having Multiple Tables?
hello to all.. can someone tell me how I counld get a pagefooter linked textbox to show a data bound page footer in a report having 8 tables....??? I have tried the common solution showed on the previous forums.. They worked when there was only one table... where in i could place a group in 1 of the cells in the table body of the report. but now since der are 8 tables in the report.. d job is become very tricky. the page footer is not showing up on all the pages of the report. it only shows on the first page of the report. Plz help...... Regards Savio.
View Replies !
An SQLDataSource On 2 Other DataSources? Show In A GridView
Hi,I have two SQLDataSources called "LeagueTableHome" an "LeagueTableAway" on my page. I want to create another SQLDataSource called "LeagueTableTotal" on my page which adds up all the totals from each of the other two sources. The datasource looks like this: Team, Pld, W, D, L, F, A, Agg, Pts my code for LeagueTableHome looks like this: SELECT HomeTeam, 1 AS Pld, CASE WHEN HomeScore > AwayScore THEN 1 ELSE 0 END AS Won, CASE WHEN HomeScore = AwayScore THEN 1 ELSE 0 END AS Draw, CASE WHEN HomeScore < AwayScore THEN 1 ELSE 0 END AS Lost, HomeScore AS Scored, AwayScore AS Against, HomeScore - AwayScore AS Agg, CASE WHEN HomeScore > AwayScore THEN 3 ELSE 0 END AS Pts FROM tblFixtures WHERE (CompID = 1) AND (HomeScore IS NOT NULL) I want then to show LeagueTableTotal in a GridView. Can anybody help?
View Replies !
GridView && SqlDataSource Delete Problem
Hi guys! I have a simple windows form where a gridview is being populated by a database. I have checked the ability to update, insert delete. And everything is fine but when i want to delete a row it throws an exeption. The exeptions says: "Must declare the scalar variable "@id"."I haven't changed the delete, update and insert commands. They are as fallowsDeleteCommand="DELETE FROM [recepti] WHERE [id] = @id"InsertCommand="INSERT INTO [recepti] ([ime], [recepta], [snimka], [snimka2], [tip]) VALUES (@ime, @recepta, @snimka, @snimka2, @tip)" SelectCommand="SELECT * FROM [recepti]"UpdateCommand="UPDATE [recepti] SET [ime] = @ime, [recepta] = @recepta, [snimka] = @snimka, [snimka2] = @snimka2, [tip] = @tip WHERE [id] = @id" The id column is auto generated, unique, also it's a primery key.So any idea where is the problem?
View Replies !
Gridview Updated + SQLDatasource + UserName
Hi I have a gridview which is using a SQLdatasource, to update the table. One of my parameters on the SP is username. At the moment on page load I am declaring a session variable Session("UserName") = me.user.identy.name I then amend the update parameter in the SQL Datasource to accept the username from the session variable. - works fine, I was however wondering if there is a way of returning the username directly into the sqldatasource without having to pass it through a session variable? regards Tom
View Replies !
GridView Using Sqldatasource Stored Procedure
hi, sorry for asking.im using a gridview and bind it to the sqldatasource.currently the im using the ide to perfrom the binding of the gridview and the sqldatasource.for the insert command, im using the sqldatasource store procedure to insert the value.the store procedure will return an error code if error was found.how was i able to get the return value, since everything was generated by the ide?
View Replies !
GridView Via SQLDataSource And Stored Procedure
Help!I am trying to fill my datagrid using the SQLDataSource, using a stored procedure.The stored procedure expects a parameter which I can collect via the querystring, or a string. How can I pass the parameter through the SQLDatasSource?My SQLDataSource is SQLData1. I already have:SQLData1.SelectCommandType = SqlDataSourceCommandType.StoredProcedureSQLData1.SelectCommand = "dbo.get_players"Thanks in advance,Karls
View Replies !
Binding A SqlDataSource, To A GridView At Runtime
Hello I'm experiencing some problems, binding a SqlDataSource to a GridView. The following code creates the SqlDataSource: string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName; SqlDataSource ds = new SqlDataSource(strProvider, strConn); ds.SelectCommand = "SELECT * FROM rammekategori"; Then i bind the SqlDataSource to a GridView: GridView1.DataSource = ds; GridView1.DataBind(); ErrorMessage: Format of the initialization string does not conform to specification starting at index 0. Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.Line 24: GridView1.DataBind();Am i totally off target here? Can it be something about, that you have to set the datasource of the gridview, before the Page_Load event? Thanks - MartinHN
View Replies !
SqlDataSource Not Updating On Editing GridView
Hi, I'm new in ASP 2.0. I need to incorporate edit and delete capability in GridView. Using the wizard, i've generated this code. When I delete a row, it gets deleted but update does not work. I've tried several ways. I got no error or exception. But row is not updated. I've checked database, and I think the update query is not executing at all. Please let me know, what I'm doing wrong? Here is the source code for reference. I'm using Visual Studio 2005 with SQL server 2005 Express Edition. Regards ========================================================== <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="QuoteItemID" DataSourceID="SqlDataSource1"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" CausesValidation="False" /> <asp:BoundField DataField="QuoteItemID" HeaderText="QuoteItemID" InsertVisible="False" ReadOnly="True" SortExpression="QuoteItemID" /> <asp:BoundField DataField="QuoteID" HeaderText="QuoteID" SortExpression="QuoteID" /> <asp:BoundField DataField="ChargeCodeID" HeaderText="ChargeCodeID" SortExpression="ChargeCodeID" /> <asp:BoundField DataField="RateItemAmount" HeaderText="RateItemAmount" SortExpression="RateItemAmount" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ratesdb %>" DeleteCommand="DELETE FROM [Quote_item] WHERE [QuoteItemID] = @QuoteItemID" InsertCommand="INSERT INTO [Quote_item] ([QuoteID], [ChargeCodeID], [RateItemAmount]) VALUES (@QuoteID, @ChargeCodeID, @RateItemAmount)" SelectCommand="SELECT * FROM [Quote_item]" UpdateCommand="UPDATE [Quote_item] SET [QuoteID] = @QuoteID, [ChargeCodeID] = @ChargeCodeID, [RateItemAmount] = @RateItemAmount WHERE [QuoteItemID] = @QuoteItemID" ConflictDetection="CompareAllValues"> <DeleteParameters> <asp:Parameter Name="QuoteItemID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="QuoteID" Type="Int32" /> <asp:Parameter Name="ChargeCodeID" Type="Int32" /> <asp:Parameter Name="RateItemAmount" Type="Decimal" /> <asp:Parameter Name="QuoteItemID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="QuoteID" Type="Int32" /> <asp:Parameter Name="ChargeCodeID" Type="Int32" /> <asp:Parameter Name="RateItemAmount" Type="Decimal" /> </InsertParameters> </asp:SqlDataSource>
View Replies !
Qestion About SQLDataSource, Gridview, And Update Panel
I have a gridview that is tied to a SQLDataSource control which is inside an update panel. What I'm trying to accomplish is when the page is loaded the gridview is filled from the SQLDataSource. I have some textboxes also on the page so that the user can add new items to the gridview. The update panel trigger is tied to my code behind page through a button click which added the new data to the DB with an INSERT statement. Since the gridview was inside the update panel I thought when I placed the new data into the DB and the update panel caused the portion of the page that holds the gridview to refresh that the gridview would show the newly added data but it is not. I am missing something but I do not know what. I tried adding a gridview1.databind() and SQLDataSource1.DataBind() but niether caused the update of the gridview as I had hoped. Thanks for any of your help. Ty
View Replies !
Binding A Gridview To Sqldatasource On Button Click
i am using 2 textbox to search name and instituition of some students. on button click need to display the result on gridview. but i dont get any result.. pl adviceSqlDataSource1.SelectCommand = "SELECT Sname, Address, Instituition, Role, Testgroup, Email FROM std_det WHERE (Sname LIKE '%'+@Param1+'%') AND (Instituition = 'RASET') AND (Role LIKE '%'+@Param2+'%') AND (Instituition = 'RASET')"; name.ControlID = "TextBox3"; name.DefaultValue = "%"; name.Name = "Param1"; name.PropertyName = "Text"; inst.ControlID = "TextBox4"; inst.DefaultValue = "%"; inst.Name = "Param2"; inst.PropertyName = "Text"; //SqlDataSource1.Select(DataSourceSelectArguments.Empty); SqlDataSource1.SelectParameters.Add(name); SqlDataSource1.SelectParameters.Add(inst); SqlDataSource1.DataBind(); //DataView dv = (DataView)this.SqlDataSource1.Select(DataSourceSelectArguments.Empty); GridView2.DataSourceID = "SqlDataSource1"; GridView2.DataBind();
View Replies !
Sqldatasource How To Not Load The Gridview With The SqldataSoruce At Page_load C#
hello all 1) I was using SQLdataSource and bind it with the gridviw to show its data. so that is how is running when the page load, i see the data is posted on the page on the gridview. But what i need to do when I want a user to click a button and then the Gridview show the data. As i was creating a SQLDatasource, it was click click and click but I want to put that sqldatasouce to load the data in gridview by a click event. 2) my second question is also related to the first one or just similar. I dont want to get all the data rather filter it. so once the page load, there is a button and a text box. In the text box user going to type the EmployeeID and click the "Employee Info" button and then the data would show up. Rather i use te DetaildView Control . What should I do to load the information on the Text boxes rather then on the GridView since it is going to be a single recrod. Thanks all
View Replies !
SqlDataSource + GridView - Scalar Variables Not Being Read
Hi all, first post, and I am desperate. I have a SqlDataSource with a Select, Update and Delete command. From what I understand, scalar variables should be read automatically from the GridView's BoundField columns when it executes a command on it. Here is my code: <asp:GridView ID="teamGrid" EmptyDataText="n/a" DataKeyNames="TeamId" AutoGenerateColumns="false" DataSourceID="teamSource" OnRowEditing="validateEdit" OnRowDeleting="validateDelete" runat="server"> <Columns> <asp:CheckBoxField DataField="TeamApproved" HeaderText="Approved" /> <asp:BoundField DataField="TeamName" HeaderText="Team Name" /> <asp:TemplateField HeaderText="City"> <ItemTemplate> <asp:Label runat="server"><%# Eval("City") %></asp:Label>, <asp:Label runat="server"><%# Eval("ProvinceCode") %></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="RequestedDivision" HeaderText="Division Req." ControlStyle-Width="60px" /> <asp:BoundField DataField="DivisionCode" HeaderText="Assigned Division" ControlStyle-Width="60px" ConvertEmptyStringToNull="true" NullDisplayText="n/a" /> <asp:BoundField DataField="DivisionNumber" HeaderText="Division Number" ControlStyle-Width="60px" ConvertEmptyStringToNull="true" NullDisplayText="n/a" /> <asp:BoundField DataField="Password" HeaderText="Password" ConvertEmptyStringToNull="true" NullDisplayText="n/a" /> <asp:CheckBoxField DataField="Paid" HeaderText="Paid" /> <asp:HyperLinkField Text="view players" ItemStyle-Width="70px" ItemStyle-HorizontalAlign="Center" DataNavigateUrlFields="TeamId" DataNavigateUrlFormatString="viewTeamPlayers.aspx?teamId={0}" ShowHeader="false" /> <asp:CommandField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="30px" ButtonType="Link" EditText="edit" ShowEditButton="true" ShowHeader="false" /> <asp:TemplateField ShowHeader="False" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="30px"> <ItemTemplate> <asp:LinkButton runat="server" CausesValidation="False" CommandName="Delete" OnClientClick='return confirm("Deleting this team will also delete the players. Are you sure you wish to continue?");' Text="delete" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:SqlDataSource ID="teamSource" ConnectionString="<%$ ConnectionStrings:MB %>" SelectCommand="SELECT TeamId, TeamName, ProvinceCode, City, DivisionCode, DivisionNumber, TeamApproved, RequestedDivision, Paid, Password, CaptainId, Player2Id, Player3Id, Player4Id FROM [Team]" UpdateCommand="UPDATE [Team] SET TeamName = @TeamName, DivisionCode = @DivisionCode, DivisionNumber = @DivisionNumber, TeamApproved = @TeamApproved, Paid = @Paid, Password = @Password WHERE TeamId = @TeamId" runat="server" /> </form> I apologize for the way the code is put in, the code thing cut off a lot of the text! The problem I'm getting is, when the 'Update' button is hit, I get the error: Must declare the variable '@TeamId'. I've tried putting "Update Parameters", that takes away the error, but the row does not update. I've browsed the internet and saw the same problems in lots of areas, but either a) none of the solutions work for me, or b) they don't really apply to my case. I'm using ASP .NET 2.0, and (obviously) C#. SQL Server database. Any help is greatly appreciated. Thanks in advance, - Branden
View Replies !
Problem Encountered With Filterparameter On SQLDataSource For GridView
Hi, I have a GridView connected to a sqldatasource control. Everything is working great, updates, paging and filtering with one exception. When the user enters in a name like O'Reilly (with a single quote), the page errors. The error returned is: Syntax error: Missing operand after 'Reilly' operator. Here is the definition of the sqldatasource: <asp:SqlDataSource ID="SqlDataSourcePersons" runat="server" ConnectionString="<%$ ConnectionStrings:database %>" SelectCommand="SELECT [Id], [FirstName], [LastName], , [PersonTypeId], [WorkerId], [_workerNTId], [Title], [City] FROM [Person]" FilterExpression="(FirstName like '{0}%') AND (LastName like '{1}%') AND (WorkerId like '{2}%') AND (City like '{3}%')" ProviderName="System.Data.SqlClient"> <FilterParameters> <asp:ControlParameter ControlID="TextBoxFirstName" Name="FirstName" DefaultValue="%" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBoxLastName" Name="LastName" DefaultValue="%" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBoxWorkerId" Name="WorkerId" DefaultValue="%" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBoxCity" Name="City" DefaultValue="%" PropertyName="Text" Type="String" /> </FilterParameters> </asp:SqlDataSource> Any suggestions would be appreciated. Thank you, Jim
View Replies !
GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)
Hi all I have a GridView on an aspx page, that is enabled for editing, deletion and sorting. In the Page_Load event of the aspx page, i add a SqlDataSource to the page, and bind the source to the GridView. When i click the update, or delete button, it makes a PostBack, but nothing is affected. I'm sure this has got something to do with the parameters. First, i tried having the GridView.AutoGenerateColumns set to True. I have also tried adding the columns manually, but no affect here either. The code for setting the commands, and adding the SqlDataSource to the page are as follows: string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName; string selectCommand = "SELECT * FROM rammekategori"; SqlDataSource ds = new SqlDataSource(strProvider, strConn, selectCommand); ds.ID = "RammeKategoriDS"; ds.UpdateCommand = "UPDATE rammekategori SET Kategoribeskrivelse = @Kategoribeskrivelse WHERE (Kategorinavn = @Kategorinavn)"; ds.DeleteCommand = "DELETE FROM rammekategori WHERE (Kategorinavn = @Kategorinavn)"; Parameter Kategorinavn = new Parameter("Kategorinavn", TypeCode.String); Parameter Kategoribeskrivelse = new Parameter("Kategoribeskrivelse", TypeCode.String); ds.UpdateParameters.Add(Kategorinavn); ds.UpdateParameters.Add(Kategoribeskrivelse); ds.DeleteParameters.Add(Kategorinavn); Page.Controls.Add(ds); SqlDataSource m_SqlDataSource = Page.FindControl("RammeKategoriDS") as SqlDataSource; if (m_SqlDataSource != null) { this.gvRammeKategorier.DataSourceID = m_SqlDataSource.ID; } As mentioned - no affect at all! Thanks in advance - MartinHN
View Replies !
Why Can't I Enable Editing On A Gridview That Gets It's Data From A View Through An SqlDataSource?
Hi, I think the title explains it all really. I cannot configure the SqlDataSource to add Insert, Update and Delete statements - not through the wizard anyway. The view combines two tables, each containing 3 columns. I have tried using different combinations of columns, and ended up selecting all of them (making sure the foreign key column of the first table was given a different alias to the primary key column of the second table) but I still cannot enable editing. Cheers, Patrick
View Replies !
Gridview Button For Calling Sqldatasource.update Fails
<!-- Trying to create a GridView Survey form: Hi [User] Do you have these assets? [Gridview] Tag Number Response 123 [Yes ] [No] [Comments textbox] 234 [Yes ] [No] [Comments textbox] Goal: The desire is for the user to click Yes or No and have the database updated with the user's name, date, response and any comments. So far, I have created SqlDataSource with Select and Update commands, created the gridview and response buttons, setup the RowCommand and On_Updating Functions. Problems:1) If I call the update() function for SqlDataSource1 and misuse the Defaultvalue parameters to run the sql, no update is posted to the database. 2) If I use the On_Update function to set the parameter values, I get "Data type mismatch in criteria expression." (Additionally, the On_Update function runs twice which I don't understand)Can anyone tell me what/why? (and how to fix it?)Sorry for the deluge, but here is the code: --> <%@ Page Language="VB" %> <html> <head id="Head1" runat="server"> <title>Asset Survey</title> </head> <SCRIPT runat="server"> Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting e.Command.Parameters("Name1").Value = User.Identity.Name End Sub Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating 'For some reason, this function executes twice '2nd execution gets error: "Data type mismatch in criteria expression." 'e.Command.Parameters("PrimaryKey1").Value = intPrimaryKey 'e.Command.Parameters("Responder1").Value = strUser 'e.Command.Parameters("ResponseDate1").Value = dtModDate 'e.Command.Parameters("Response1").Value = strResponse 'e.Command.Parameters("ResponseComments1").Value = strComments End Sub Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) _ Handles GridView1.RowCommand Dim GridRow1 As Integer = Convert.ToInt32(e.CommandArgument) If e.CommandName = "UpdateYes" Then 'code here to disable buttons and textbox '... SqlDataSource1.UpdateParameters("Response1").DefaultValue = "Yes" End If If e.CommandName = "UpdateNo" Then 'code here to disable buttons and textbox '... SqlDataSource1.UpdateParameters("Response1").DefaultValue = "No" End If 'if I use the SqlDataSource1_Updating function, I get the mismatch error 'but if I (mis)use the DefaultValue parameter, no update occurs. SqlDataSource1.UpdateParameters("ResponseComments1").DefaultValue = _ GridView1.Rows(GridRow1).FindControl("txtComments").ToString SqlDataSource1.UpdateParameters("Responder1").DefaultValue = User.Identity.Name SqlDataSource1.UpdateParameters("ResponseDate1").DefaultValue = DateTime.Now SqlDataSource1.UpdateParameters("PrimaryKey1").DefaultValue = _ GridView1.Rows(GridRow1).Cells(0).Text Try SqlDataSource1.Update() 'Error Here if I use on_updating: "Data type mismatch in criteria expression." Catch except As Exception ' Handle the Exception. End Try End Sub </SCRIPT> <body> <form id="formInv" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LocalTestMDB %>" ProviderName="<%$ ConnectionStrings:LocalTestMDB.ProviderName %>" SelectCommand="SELECT [PrimaryKey], [Name], [AssetTag], [Response], [Responder], [ResponseDate],[ResponseComments] FROM [Tablename] WHERE ([Name] = ?) ORDER BY [Login Name], [AssetTag]" UpdateCommand="Update [Tablename] SET [Response]=@Response1, [Responder]=@Responder1, [ResponseDate]=ResponseDate1, [ResponseComments]=ResponseComments1 WHERE [PrimaryKey]=@PrimaryKey1" OnSelecting="SqlDataSource1_Selecting" OnUpdating="SqlDataSource1_Updating"> <SelectParameters> <asp:Parameter DefaultValue="" Name="Name1" Type=String /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="ResponseComments1" Type=String DefaultValue="" /> <asp:Parameter Name="Response1" Type=String DefaultValue="" /> <asp:Parameter Name="ResponseDate1" Type=DateTime DefaultValue="#8/1/2007 12:00:00PM#" /> <asp:Parameter Name="Responder1" Type=String DefaultValue="" /> <asp:Parameter Name="PrimaryKey1" Type=Int32 DefaultValue=0 /> </UpdateParameters> </asp:SqlDataSource> <span>Hi, Please respond by clicking "Yes" or "No" for each asset</span> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PrimaryKey" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="PrimaryKey" HeaderText="PrimaryKey" AccessibleHeaderText="PrimaryKey" Visible=False/> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" AccessibleHeaderText="Name" /> <asp:BoundField DataField="AssetTag" HeaderText="AssetTag" SortExpression="AssetTag" AccessibleHeaderText="AssetTag" /> <asp:TemplateField HeaderText="Please Respond"> <ItemTemplate> <asp:Button ID="btnYes" runat="server" Text="Yes" Visible="true" CommandName='UpdateYes' CommandArgument='<%# CType(Container, GridViewRow).RowIndex %>' /> <asp:Button ID="btnNo" runat="server" Text="No" Visible="true" CommandName='UpdateNo' CommandArgument='<%# CType(Container, GridViewRow).RowIndex %>' /> <br /> <asp:Label ID="lblComments" runat="server" Text="Comments:" Visible=True></asp:Label> <asp:TextBox ID="txtComments" runat="server" Text='<%# Bind("ResponseComments") %>' Visible=True MaxLength=512 Height=24 Width=320 Wrap=True Enabled=True TextMode=MultiLine></asp:TextBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html>
View Replies !
Performance Comparison - Code Vs SqlDataSource, Gridview Etc Vs PlainControl
There are so many ways to use database in asp.net/ado.net, I'm a bit confused about their difference from the performance point of view.So apparently SqlDataSource in DataReader mode is faster than DataSet mode, at a cost of losing some bolt-on builtin functions.What about SqlDataSource in DataReader mode vs manual binding in code? Say creating a SqlDataSource ds1 and set "DataSourceID" in Gridview, vs manually creating the SqlConnection, SqlCommand, SqlDataReader objects and mannually bind the myReader object to the gridview with the Bind() method.Also Gridview is a very convenient control for many basic tasks. But for more complex scenarios it requires lots of customization and modification. Now if I do not use gridview at all and build the entire thing from scratch with basic web controls such as table and label controls, and mannually read and display everything from a DataReader object, how's the performance would be like compared to the Gridview-databind route?
View Replies !
Problem To Retrieve Data With Help Of SP And Sqldatasource,gridview,controls
Hello, I m creating my application in ASP.Net 2005 C# with the backend SQL Server 2005. On my first form i have used some label,textboxs,dropdownlists,radiobutton and checkbox. On the click event of the button the data gets stored into the database.I have created the stored procedures for the insert,update,delete. I have used sqldatasource for the connection to server and storing data. On submit click event it should be inserted and displayed on the grid. Now,what i want to know is anything missing in the following code on the submit click event as the data is not inserted and shown in the gridview.If i write the simple sql insert query then there's no problem.The problem is with the stored procedure which is used in C#.In sql server the stored procedure executes correctly. The stored procedure is running on the sql-server so there must be problem on the click event. Is any variables which are used in stored procedure are to be noted ? SQL 2005 DATABASE TABLE DETAILS 1) employee_table PKEmployeeid int(4) NOT NULL (TEXTBOX CONTROL –AUTOGENERATED) FKLocationid int(4)NOT NULL (LABEL CONTROL -- AUTOGENERATED) Employeename varchar(15)NOT NULL (TEXTBOX CONTROL) City varchar(15) (DROPDOWNLIST CONTROL) Joindate datetime (DATEPICKER ) Salary money (TEXTBOX CONTROL) 2) location_table PKLocationid int(4)NOT NULL (LABEL CONTROL -- AUTOGENERATED) Locationname varchar(15)NOT NULL (TEXTBOX CONTROL) GRIDVIEW <asp:GridView ID="GridView1" runat="server" AutoGenerateSelectButton="true" SelectedRowStyle-CssClass="selectedRow" DataSourceID="SqlDataSource1" DataKeyNames="employeeid,locationid" > <InsertParameters> <asp:Parameter Name="employeeid" Direction="Output" /> <asp:Parameter Name="locationid" Direction="Output" /> <asp:Parameter Name="employeename" Type="String" Direction="Input"/> <asp:Parameter Name="city" Type="String" Direction="Input"/> <asp:Parameter Name="joindate" Type="Datetime" Direction="Input"/> <asp:Parameter Name=''salary'' Type="INT16" Direction="Input"/> <asp:Parameter Name="locationname" Type="String" Direction="Input"/> </InsertParameters> <asp:GridView / > SQLDATASOURCE <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:employee_table,location_table %>" ProviderName="System.Data.SqlClient" InsertCommand="EmpLocationInsertJoin" InsertCommandType="StoredProcedure"/> C# CODE protected void Page_Load(object sender, EventArgs e) { GridView1.Visible = false; } protected void cmdsubmit_Click(object sender, EventArgs e) { string employeename = tbemployeename.Text.ToString(); string locationname = tblocationname.Text.ToString(); tbemployeeid.Text=command.Parameters["employeeid"].Value.ToString(); tblocationid.Text=command.Parameters["locationid"].Value.ToString(); SqlDataSource1.InsertParameters[0].DefaultValue = employeename; SqlDataSource1.InsertParameters[1].DefaultValue = locationname; SqlDataSource1.InsertParameters[2].DefaultValue = city; SqlDataSource1.InsertParameters[3].DefaultValue = joindate; SqlDataSource1.InsertParameters[4].DefaultValue = salary; SqlDataSource1.Insert(); GridView1.Visible = true; } protected void cmdview_Click(object sender, EventArgs e) { GridView1.Visible = true; } I want to perform the edit and delete with the commandfield of edit and delete which are present in the gridview. Pls give me the reply at the earliest...
View Replies !
Prevent Loading Sqldatasource And Populating Gridview On Pageload
Hi, I got a page with 3 sqldatasources and 2 dropdownlists and 1 gridview. 2 sqldatasources may load when the page load adn fill in the 2 DDL's. But 1 sqldatasource and the gridview may only be loaded when I press a button. This is because otherwise every time I load the page more then 5000 records. (the 2 DDL's are filters for the 3th sqldatasource) Anyone an idea how to solve this problem? Best regards, Karel
View Replies !
Retrieving Selected Gridview Column Values For SQLDatasource Asp:controlparameters
Not sure if this is the correct forum, but I 'm having problems retrieving a sqldatasource's asp:control parameter values from a selected row (during edit) in a gridview to update a record thru a stored procedure. The stored procedure is pretty intense, so I'd like to keep it in SQL if possible instead of creating the generic "update table set ..." that I see in most examples. It seems as if I can't get the propertyname right or something because it keeps giving me a "Procedure or function XX has too many arguments specified error". Maybe the DataKeyNames is not right?? I've tried just passing one parameter (ProductID-same as DataKeyNames) using "SelectedValue" as propertyname and still get the same. It's got to be something very simple, but I'm at a loss. All parameters are spelled the same in the sp (with an added "@" at start) as in the asp:controlparameters. Here's the gridview (asp.net 2.0 connecting to SQL Server 2005): <asp:GridView ID="gvLoadEditProductPrices" runat="server" AutoGenerateColumns="False" AllowSorting="True" DataSourceID="SqlDataSource1" DataKeyNames="ProductID"> <Columns> <asp:CommandField ShowEditButton="True" /> <asp:BoundField DataField="ProductID" HeaderText="ProductID" HeaderStyle-BackColor="white" InsertVisible="False" ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="Product" HeaderText="Product" SortExpression="Product" ReadOnly="True" /> <asp:BoundField DataField="ProductCat" HeaderText="ProductCat" SortExpression="ProductCat" ReadOnly="True" /> <asp:BoundField DataField="VarRate" HeaderText="VarRate" SortExpression="VarRate" /> <asp:BoundField DataField="loadid" HeaderText="loadid" InsertVisible="False" ReadOnly="True" SortExpression="loadid" /> <asp:BoundField DataField="loadamount" HeaderText="loadamount" SortExpression="loadamount" ReadOnly="True" /> <asp:BoundField DataField="ProductCol" HeaderText="ProductCol" SortExpression="ProductCol" ReadOnly="True" /> <asp:BoundField DataField="PageID" HeaderText="PageID" SortExpression="PageID" ReadOnly="True" /> </Columns> </asp:GridView> and the sqldatasource's info: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MARSProductEditor %>" ProviderName="System.Data.SqlClient" SelectCommand="spGetLoadEditProductPrices" SelectCommandType="StoredProcedure" UpdateCommand="spUpdateProductPrices" UpdateCommandType="StoredProcedure" > <UpdateParameters> <asp:ControlParameter Name="ProductID" Type="Int32" ControlID="gvLoadEditProductPrices" PropertyName=SelectedDataKey.Values("ProductID")></asp:ControlParameter> <asp:ControlParameter Name="LoadID" Type="Int32" ControlID="gvLoadEditProductPrices" PropertyName=SelectedDataKey.Values("LoadID")></asp:ControlParameter> <asp:ControlParameter Name="PageID" Type="Int32" ControlID="gvLoadEditProductPrices" PropertyName=SelectedDataKey.Values("PageID")></asp:ControlParameter> <asp:ControlParameter Name="ProductCol" Type="Int32" ControlID="gvLoadEditProductPrices" PropertyName=SelectedDataKey.Values("ProductCol")></asp:ControlParameter> <asp:ControlParameter Name="NewRate" Type="Double" ControlID="gvLoadEditProductPrices" PropertyName=SelectedDataKey.Values("NewRate")></asp:ControlParameter> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="ddlEstLoadsPerAcre" Name="LoadID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="txtEditType" Name="PageName" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> TIA, John
View Replies !
Gridview - SqlDatasource - How Do You Get All Values For A Like Text Parameter Or A Boolean Field When Filtering?
I have a gridview connected to a sqldatasource, and it works pretty good. It gives me the subsets of the information that I need. But, I really want to let them choose all the companies and/or any status. What's the best way to get all the values in the gridview...besides removing the filters :) I thought the company would be easy, I'd just set the selected value to blank "", and then it'd get them all....but that's not working. And, for the boolean, I have no idea to get the value without having a separate query. (tabs_done=@tabsdone) and (company like '%' + @company + '%')1 <asp:DropDownList ID="drpdwnProcessingStatus" runat="server"> 2 <asp:ListItem Value="0">Open</asp:ListItem> 3 <asp:ListItem Value="1">Completed</asp:ListItem> 4 </asp:DropDownList> 5 6 7 <asp:DropDownList ID="drpdwnCompany" runat="server"> 8 <asp:ListItem Value="">All</asp:ListItem> 9 <asp:ListItem Value="cur">Cur District</asp:ListItem> 10 <asp:ListItem Value="jho">Jho District</asp:ListItem> 11 <asp:ListItem Value="sea">Sea District</asp:ListItem> 12 <asp:ListItem Value="san">Net District</asp:ListItem> 13 <asp:ListItem Value="sr">Research District</asp:ListItem> 14 </asp:DropDownList> 15 16 17 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HRFormsConnectionString %>" 18 SelectCommand="SELECT DISTINCT [id], [lastname], [company] FROM [hr_term] hr where (tabs_done=@tabsdone) and (company like '%' + @company + '%')"> 19 <SelectParameters> 20 <asp:ControlParameter ControlID="drpdwnProcessingStatus" DefaultValue="0" Name="tabsdone" PropertyName="SelectedValue" /> 21 <asp:ControlParameter ControlID="drpdwnCompany" DefaultValue="" Name="company" PropertyName="SelectedValue" /> 22 </SelectParameters> 23 </asp:SqlDataSource> 24
View Replies !
Issue With Getting Values From Child Controls In A Gridview, To Use For The Update Using A SQLDataSource Control
Hi all, I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code: <asp:GridView ID="GridEditSettlement" runat="server" AutoGenerateColumns="False" BackColor="Navy" BorderColor="IndianRed" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Small" DataSourceID="SqlDataSource_grid" AllowPaging="True" AllowSorting="True" ForeColor="White" DataKeyNames="legid"> <Columns> <asp:CommandField ShowEditButton="True" CancelImageUrl="~/App_Graphics/quit.gif" CancelText="" EditImageUrl="~/App_Graphics/EditGrid.GIF" EditText="" UpdateImageUrl="~/App_Graphics/save.gif" UpdateText="" ButtonType="Image" /> <asp:BoundField DataField="StartDate" HeaderText="Start Date" ReadOnly="True" /> <asp:BoundField DataField="EndDate" HeaderText="End Date" ReadOnly="True" /> <asp:BoundField DataField="CounterpartDealRef" HeaderText="CP Deal Ref" ReadOnly="True" /> <asp:TemplateField HeaderText="Preliminary Settlement Price" ><ItemTemplate> <asp:Label ID=lblPreliminary runat=server Text='<%# Bind("PrimarySettlementPrice") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID=txtPrimaryPrice Text='<%# Bind("PrimarySettlementPrice") %>'></asp:TextBox> </EditItemTemplate></asp:TemplateField> <asp:TemplateField HeaderText="Agreed Settlement Price"><ItemTemplate> <asp:Label ID=lblAgreed runat=server Text='<%# Bind("AgreedSettlementPrice") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID=txtAgreedPrice Text='<%# Bind("AgreedSettlementPrice") %>'></asp:TextBox> </EditItemTemplate></asp:TemplateField> <asp:BoundField DataField="Volume" HeaderText="Volume" ReadOnly="True" /> <asp:BoundField DataField="Price" HeaderText="Price" ReadOnly="True" /> <asp:BoundField DataField="TotalVolume" HeaderText="Total Volume" ReadOnly="True" /> <asp:BoundField DataField="InstrumentName" HeaderText="Instrument" ReadOnly="True" /> <asp:BoundField DataField="NominalValue" HeaderText="Nominal Value" ReadOnly="True" /> <asp:BoundField DataField="Strike" HeaderText="Strike" ReadOnly="True" /> <asp:BoundField DataField="DeliveryDate" HeaderText="Delivery Date" ReadOnly="True" /> <asp:TemplateField HeaderText="LegId" SortExpression="LegId"> <ItemTemplate> <asp:Label ID="lblLegID" runat="server" Text='<%# Bind("LegId") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID=txtLegID Text='<%# Bind("LegId") %>'></asp:TextBox> </EditItemTemplate> </asp:TemplateField> </Columns> <RowStyle BackColor="#FFFF66" ForeColor="#333333" /> <EditRowStyle BackColor="#FFFF66" Font-Names="Verdana" Font-Size="X-Small" ForeColor="#333333" /> <PagerStyle ForeColor="White" /> <AlternatingRowStyle BackColor="White" ForeColor="#333333" /> </asp:GridView> <br /> <asp:SqlDataSource ID="SqlDataSource_grid" runat="server" ConnectionString="<%$ ConnectionStrings:DealCaptureDev %>" SelectCommand="sp_get_single_deal" SelectCommandType="StoredProcedure" UpdateCommand="Update trDealLeg Set PrimarySettlementPrice=@primarysettlement, AgreedSettlementprice=@agreedsettlement, LastUpdate=GetDate(), LastUpdateBy=Session('userid') Where LegID=@legid" EnableCaching="True" ConflictDetection="CompareAllValues" ProviderName="System.Data.SqlClient"> <SelectParameters> <asp:QueryStringParameter DefaultValue="" Name="dealnum" QueryStringField="deal" Type="String" /> </SelectParameters> <UpdateParameters> <asp:ControlParameter ControlID="txtLegId" PropertyName="Text" Name="legId" /> <asp:ControlParameter ControlID="txtPrimarySettlement" Name="primarysettlement" PropertyName="Text" /> <asp:ControlParameter ControlID="txtAgreedSettlement" Name="agreedsettlement" PropertyName="Text"/> <asp:SessionParameter DefaultValue="" Name="userid" SessionField="userid" /> </UpdateParameters> </asp:SqlDataSource> As seen above, controls such as txtPrimarySettlement are referenced but the update is not successful. The text boxes are within the GridEditSettlement gridview. In the .aspx code I cannot use FindControl (at least I don't think it will work). So the questions are: Is it possible to reference the child controls, if so - how? Is there another way to do this, such as in the vb code behind - in the either the gridview's RowUpdating event or the SQLDataSource's Updating event. What is the best approach? Anyone come up against this issue before? Thanks, KB
View Replies !
Stored Procedure Passes Test In Gridview, But Nothing Shows Up On The Page
Like the subject says I have tested the SP in Gridview. Everything looks fine. But when run nothing shows up on the page. I have tried using QueryStrings to pass the data and Controls. Here is the Gridview Code:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1"> <FooterStyle BackColor="#99CCCC" ForeColor="#003399" /> <RowStyle BackColor="White" ForeColor="#003399" /> <Columns><asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /><asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /><asp:BoundField DataField="EthnicID" HeaderText="EthnicID" SortExpression="EthnicID" /><asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" /><asp:BoundField DataField="Height" HeaderText="Height" SortExpression="Height" /><asp:BoundField DataField="Weight" HeaderText="Weight" SortExpression="Weight" /> <asp:BoundField DataField="Hair" HeaderText="Hair" SortExpression="Hair" /> <asp:BoundField DataField="Eyes" HeaderText="Eyes" SortExpression="Eyes" /> <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /> <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" /> </Columns> <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /> <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /> <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /> </asp:GridView> Here is the Datasource:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQL2005_311004_modelsystemConnectionString %>" SelectCommand="spSearch" SelectCommandType="StoredProcedure"> <SelectParameters><asp:QueryStringParameter DefaultValue="" Name="FirstName" QueryStringField="fn" Type="String" /> <asp:QueryStringParameter Name="LastName" QueryStringField="ln" Type="String" /> <asp:Parameter Name="EthnicID" Type="String" /> <asp:Parameter Name="Gender" Type="String" /> <asp:Parameter Name="Height" Type="String" /> <asp:Parameter Name="weight" Type="String" /> <asp:Parameter Name="Hair" Type="String" /> <asp:Parameter Name="Eyes" Type="String" /> <asp:Parameter Name="City" Type="String" /> <asp:Parameter Name="State" Type="String" /> </SelectParameters> </asp:SqlDataSource> I hope you can help me with this one!!!
View Replies !
Gridview Select
I am using a GridView which is select enabled. I have another sqldatasource control on my page which will run a SQL query but needs a parameter. This parameter is from a column (EmployeeID) of the selected row in the gridview. In the Sqldatasource control I have specified the parameter source as a control which is Gridview .But I dont know how to point to the EmployeeID column of the selected row.Please help.
View Replies !
SQLDataSource Cntrl - FormView Cntrl - UPD Sproc And Sproc Debugger. I Dare Anyone To Figure This One Out.
I have attached the results of checking an Update sproc in the Sql database, within VSS, for a misbehaving SqlDataSource control in an asp.net web application, that keeps telling me that I have too many aurguments in my sproc compared to what's defined for parameters in my SQLdatasource control..... No rows affected. (0 row(s) returned) No rows affected. (0 row(s) returned) Running [dbo].[sp_UPD_MESample_ACT_Formdata] ( @ME_Rev_Nbr = 570858 , @A1 = No , @A2 = No , @A5 = NA , @A6 = NA , @A7 = NA , @SectionA_Comments = none , @B1 = No , @B2 = Yes , @B3 = NA , @B4 = NA , @B5 = Yes , @B6 = No , @B7 = Yes , @SectionB_Comments = none , @EI_1 = N/A , @EI_2 = N/A , @UI_1 = N/A , @UI_2 = N/A , @HH_1 = N/A , @HH_2 = N/A , @SHEL_1 = 363-030 , @SHEL_2 = N/A , @SUA_1 = N/A, @SUA_2 = N/A , @Cert_Period = 10/1/06 - 12/31/06 , @CR_Rev_Completed = Y ). No rows affected. (0 row(s) returned) @RETURN_VALUE = 0 Finished running [dbo].[sp_UPD_MESample_ACT_Formdata]. The program 'SQL Debugger: T-SQL' has exited with code 0 (0x0). And yet every time I try to update the record in the formview online... I get Procedure or function sp_UPD_MESample_ACT_Formdata has too many arguments specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Procedure or function sp_UPD_MESample_ACT_Formdata has too many arguments specified.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. I have gone through the page code with a fine tooth comb as well as the sproc itself. I have tried everything I can think of, including creating a new page and resetting the fields, in case something got broken that I can't see. Does anyone have any tips or tricks or info that might help me? Thanks, SMA49
View Replies !
Select Parameters With Gridview
I have a form that has 4 fields to fill in. I have a button that can add these fields to a sql database. I also want to put a button next to the "add" button so you can fill out the same fields and search for those values. Here's what i have so far. I want to select based on the fields, but i'm having trouble with the syntax of the parameters. I also want to add something, so if nothing is filled out in one of those boxes, it retuns back all records for the default value. string strConnection = ConfigurationManager.ConnectionStrings["TimeAccountingConnectionString"].ConnectionString; SqlConnection myConnection = new SqlConnection(strConnection); String selectCmd = "SELECT * FROM users WHERE firstname = @firstame or lastname = @lastname or office = @office or team = @team"; SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection); myCommand.SelectCommand.Parameters.Add(new SqlParameter("@firstname", SqlDbType.VarChar, 50)); myCommand.SelectCommand.Parameters.Add("@firstname", txtFirstName.Text); myCommand.Parameters.AddWithValue("@lastname", txtLastName.Text); myCommand.Parameters.AddWithValue("@team", dwnTeam.Text); myCommand.Parameters.AddWithValue("@office", dwnOffice.Text); DataSet ds = new DataSet(); myCommand.Fill(ds, "users"); MyDataGrid.DataSource = ds.Tables["users"].DefaultView; MyDataGrid.DataBind();
View Replies !
Gridview / SqlDataSource Error - Procedure Or Function &<stored Procedure Name&> Has Too Many Arguments Specified.
Can someone help me with this issue? I am trying to update a record using a sp. The db table has an identity column. I seem to have set up everything correctly for Gridview and SqlDataSource but have no clue where my additional, phanton arguments are being generated. If I specify a custom statement rather than the stored procedure in the Data Source configuration wizard I have no problem. But if I use a stored procedure I keep getting the error "Procedure or function <sp name> has too many arguments specified." But thing is, I didn't specify too many parameters, I specified exactly the number of parameters there are. I read through some posts and saw that the gridview datakey fields are automatically passed as parameters, but when I eliminate the ID parameter from the sp, from the SqlDataSource parameters list, or from both (ID is the datakey field for the gridview) and pray that .net somehow knows which record to update -- I still get the error. I'd like a simple solution, please, as I'm really new to this. What is wrong with this picture? Thank you very much for any light you can shed on this.
View Replies !
|