Filter Data And Update GridView

May 11, 2008

I have a GridView that gets data from an SqlDataSource. It works fine, but now when I want to filter the results and add more parameters to my sql query, nothing happens. My initial select statement in the SqlDataSource contains only 2 parameters, so now when a user clicks a Button, onclick I call a function that is supposed to change the select statement of the SqlDataSource, add 2 more parameters taken from 2 controls, and then update the GridView. This is what I use: dataSource.SelectCommand = "new select command here";  dataSource.SelectParameters.Add("State", txtState.Text); dataSource.SelectParameters.Add("City", txtCity.Text);  grid.DataBind(); It compiles, but when I click the button to filter the results, the GridView always looks the same as if nothing happened. I do not know if this is the right way to do it, or am I on the wrong track? Help is appreciated. Thank you in advance.

View 2 Replies


ADVERTISEMENT

Gridview Refresh After Update

Aug 14, 2006

Hi All,
I am new to development of asp. I have an SQLDataSource set as the data source for a grid view.  When I click on the edit link in the Gridview, change the data, and click update, the old data  is still displayed in the row.
I found exact same issue as here -- http://forums.asp.net/thread/1217014.aspx
Solution in the above thread is to add this
            {                if (reader != null) reader.Close();            }            conn.Close();
How do I apply above solution in my situation ?
 
I am updating through stored procedure.and don't have code at background.  My code is
Datasource :
<asp:SqlDataSource
ID="ds"
runat="server"
ConnectionString="<%$ ConnectionStrings:ds %>"

CancelSelectOnNullParameter="False"
ProviderName="<%$ ConnectionStrings:ds.ProviderName%>"
UpdateCommand="usp_save"
UpdateCommandType="StoredProcedure"
EnableCaching="False">
 
<UpdateParameters>
<asp:Parameter Name="field1" Type="String" />
<asp:Parameter Name="field2" Type="String" />
<asp:Parameter Name="field3" Type="String" />
<asp:Parameter Name="field4" Type="String"/>
<asp:ControlParameter Name="field5" Type="String" ControlID = "label7" />
</UpdateParameters>
 

View 8 Replies View Related

UPDATE Not Working In Gridview

Sep 26, 2006

I am trying to update a field in gridview. My update is not working, sort of. The original value is being updated with a NULL value when I click on the update button.here is my code <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" AutoGenerateEditButton="True" DataKeyNames="rqt_id">UpdateCommand="UPDATE [rqt_data] SET [rqt_title]=@rqt_title WHERE [rqt_id] = @rqt_id" >      <asp:Parameter Name="rqt_title" Type="String" /> the field rqt_title is set up as a NVarChar(25) in the db. I can't specify that for the Type property. Could that be the issue?thx

View 4 Replies View Related

Maually Update Gridview

May 21, 2007

I want to write the results of a checkbox to my database, but I am stuck on the syntax?
Here's what I have so far, could somebody pleae help., my aim is to not show a line when checkbox ticked, not to actually delete the record from the database

Hi, The problem that I have now is that yes I want to delete from gridview, but I still want the old record to be in database ,not deleted. Does anybody know how I can evaluate my checkbox, and update to the database the results of the checkbox,I am not sure of the update syntax?string strsql = "update * from jobs order by ID asc";
 SqlConnection conn = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter(strsql, conn);DataSet ds = new DataSet();ad.Fill(ds, "TASKS");
GridView1.DataSource = ds;
GridView1.DataBind();
got stuck here, basically I cant work out how to evauate the results of a checkbox, and write back to the database, can anybody help?

View 1 Replies View Related

GridView Update - Validation?

Apr 23, 2008

design view is great, just drag on a gridview make it link to my database and poof there is all my data! I can even click the "allow editting button" and poof I can edit my data.
 But how do assign validation rules? because atm if someone tries to edit my name field at puts in "asdfasdkfhdsgasdgaga" which is too long, clicks update it goes to a horrible error page. How can I catch these errors and make a nice message instead?
 
Thanks very much
 

View 2 Replies View Related

Update In Gridview Not Working

Jan 5, 2006

I may have posted this in the wrong forum before, but i am trying to update a table in SQL2000 from asp.net2.0 gridview. I follow all the recommended ways and it doesnt update the row. Please help
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="ID" CellPadding="4" ForeColor="#333333" GridLines="None">
 
.......misc code.........
UpdateCommand="UPDATE vacationrequest SET hrapprvl = @hrapprvl, notes = @notes WHERE ([ID] = @original_ID)">
<SelectParameters>
<asp:ControlParameter ControlID="HiddenField1" Name="StartDate" PropertyName="Value"
Type="DateTime" />
<asp:Parameter DefaultValue="false" Name="hrapprvl" Type="Boolean" />
</SelectParameters>

<UpdateParameters>
<asp:Parameter Type=Boolean Name="hrapprvl" />
<asp:Parameter type=String Name="notes" />
<asp:Parameter Name="original_ID"/>

View 1 Replies View Related

GridView UPDATE Problem

Apr 3, 2006

Hi GutysI am having problem with my UPDATE in GridView, it is  saying that I have too many argument, I don't This happens when I click the UpdateCommand in GRIDVIEW Procedure or function UpdateCountry has too many arguments specified.<asp:SqlDataSource ID="mySqlDataSource" Runat="server"             SelectCommandType="StoredProcedure"  SelectCommand="ShowCountry"             UpdateCommandType="StoredProcedure"  UpdateCommand="UpdateCountry"            ConnectionString="<%$ ConnectionStrings:ConnString %>">                <UpdateParameters>                <asp:Parameter Type="String" Name="CountryName"></asp:Parameter>                <asp:Parameter Type="String" Name="CountryID"></asp:Parameter>            </UpdateParameters>  </asp:SqlDataSource>Just In case these are my Stored Procedures**************************************************************************CREATE PROCEDURE [dbo].[UpdateCountry] @CountryName varchar(50),@CountryID varchar(50)ASUPDATE   EkeanyanwuO.tCountry SET [CountryName] = @CountryName WHERE [CountryID] = @CountryIDGO************************************************************************************CREATE PROCEDURE [dbo].[ShowCountry] ASSELECT     TOP 100 PERCENT EkeanyanwuO.tIMSREGION.ImsRegionName AS ImsRegionName, EkeanyanwuO.tCountry.CountryName AS CountryName,                       EkeanyanwuO.tIMSREGION.ImsRegionID AS ImsRegionID, EkeanyanwuO.tCountry.CountryID AS CountryIDFROM         EkeanyanwuO.tCountry INNER JOIN                      EkeanyanwuO.tIMSREGION ON EkeanyanwuO.tCountry.ImsRegionID = EkeanyanwuO.tIMSREGION.ImsRegionIDORDER BY EkeanyanwuO.tCountry.CountryNameGO************************************************************************************

View 1 Replies View Related

GridView Wont Delete Or Update

Nov 15, 2006

I have had this problem before but it turned out to be dodgy SQL created by the wizard. Doesn't seem to be the case this time.The following does a postback but makes no changes.  1 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ehlConnectionString %>"
2 DeleteCommand="DELETE FROM [tblSubRegions] WHERE [SubRegionID] = ?"
3 InsertCommand="INSERT INTO [tblSubRegions] ([SubRegionID], [RegionID], [SubRegionName]) VALUES (?, ?, ?)"
4 ProviderName="<%$ ConnectionStrings:ehlConnectionString.ProviderName %>"
5 SelectCommand="SELECT tblSubRegions.SubRegionID, tblSubRegions.RegionID, tblSubRegions.SubRegionName, tblRegions.RegionName FROM (tblSubRegions INNER JOIN tblRegions ON tblSubRegions.RegionID = tblRegions.RegionID) WHERE (tblSubRegions.RegionID = ?) ORDER BY tblSubRegions.SubRegionName"
6 UpdateCommand="UPDATE [tblSubRegions] SET [RegionID] = ?, [SubRegionName] = ? WHERE [SubRegionID] = ?">
7
8 <DeleteParameters>
9 <asp:Parameter Name="SubRegionID" Type="Int32" />
10 </DeleteParameters>
11
12 <UpdateParameters>
13 <asp:Parameter Name="RegionID" Type="Int32" />
14 <asp:Parameter Name="SubRegionName" Type="String" />
15 <asp:Parameter Name="SubRegionID" Type="Int32" />
16 </UpdateParameters>
17
18 <SelectParameters>
19 <asp:ControlParameter ControlID="dropRegions" Name="RegionID" PropertyName="SelectedValue" Type="Int32" />
20 </SelectParameters>
21
22 <InsertParameters>
23 <asp:Parameter Name="SubRegionID" Type="Int32" />
24 <asp:Parameter Name="RegionID" Type="Int32" />
25 <asp:Parameter Name="SubRegionName" Type="String" />
26 </InsertParameters>
27
28 </asp:SqlDataSource>
29
30
31
32 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ehlConnectionString %>"
33 ProviderName="<%$ ConnectionStrings:ehlConnectionString.ProviderName %>"
34 SelectCommand="SELECT [RegionID], [RegionName] FROM [tblRegions]">
35
36 </asp:SqlDataSource>
37
38
39
40 <asp:DropDownList id="dropStates" runat="server" OnSelectedIndexChanged="dropStates_SelectedIndexChanged" AutoPostBack="True">
41 </asp:DropDownList>
42
43 <asp:DropDownList id="dropRegions" runat="server" OnSelectedIndexChanged="dropRegions_SelectedIndexChanged" AutoPostBack="True">
44 </asp:DropDownList>
45
46
47
48 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
49 AutoGenerateColumns="False" EnableViewState=false Width="100%" DataSourceID="SqlDataSource1">
50 <Columns>
51 <asp:TemplateField HeaderText="SubRegionName" SortExpression="SubRegionName">
52 <EditItemTemplate>
53 <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
54 DataTextField="RegionName" DataValueField="RegionID" SelectedValue='<%# Bind("RegionID") %>'>
55 </asp:DropDownList>
56 </EditItemTemplate>
57 <ItemTemplate>
58 <asp:Label ID="Label1" runat="server" Text='<%# Bind("SubRegionName") %>'></asp:Label>
59 </ItemTemplate>
60 </asp:TemplateField>
61 <asp:BoundField DataField="RegionName" HeaderText="RegionName" SortExpression="RegionName" />
62 <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
63 </Columns>
64 </asp:GridView>
 Thanks in advance. Shaun 

View 1 Replies View Related

Question About GridView Update Query

Nov 15, 2007

 I try to calculate a field value and update other. It almost worksUPDATE t_Shopping_cart SET [Product_code] = @Product_code, [Quantity] = @Quantity, [Total] = Quantity * Price WHERE ([Product_code] = @Product_code)I try to update t_Shopping_cart table with quantity values from grid view and calculate sum of products (quantity*Price). Best I can get is that quantity values are old. Some comments about my query:Price is also a field in table and control. [Product_code] = @Product_code part is probably not needed. Any ideas?Leif 

View 4 Replies View Related

How To Enable Update, Delete In Gridview

Jan 2, 2008

Hi all,Happy New Year!I've just install VS .NET 2005 and try to play with Gridviewwhen I configure the datasource for Gridview and click "Advance" in order to enable Update, Delete Select etc...the checkBox is not selectableCan someone pls show me how?Thanks in advance.

View 2 Replies View Related

Aaargh! Storedproc Vs SQL In Gridview Update

Jan 26, 2006

When I attempt to update using a stored procedure I get the error 'Incorrect syntax near sp_upd_Track_1'. The stored procedure looks like the following when modified in SQLServer:
ALTER PROCEDURE [dbo].[sp_upd_CDTrack_1]
(@CDTrackName nvarchar(50),
@CDArtistKey smallint,
@CDTitleKey smallint,
@CDTrackKey smallint)
AS
BEGIN

SET NOCOUNT ON;
UPDATE [Demo1].[dbo].[CDTrack]
SET [CDTrack].[CDTrackName] = @CDTrackName
WHERE [CDTrack].[CDArtistKey] = @CDArtistKey
AND [CDTrack].[CDTitleKey] = @CDTitleKey
AND [CDTrack].[CDTrackKey] = @CDTrackKey
END
But when I use the following SQL coded in the gridview updatecommand it works:
        "UPDATE [Demo1].[dbo].[CDTrack]
   SET [CDTrack].[CDTrackName] = @CDTrackName
 WHERE [CDTrack].[CDArtistKey] = @CDArtistKey
   AND [CDTrack].[CDTitleKey]  = @CDTitleKey
   AND [CDTrack].[CDTrackKey]  = @CDTrackKey"
Whats the difference? The storedproc executes ok in sql server and I guess that as the SQL version works all of my databinds are correct. Any ideas, thanks, James.
 

View 2 Replies View Related

Filtered Gridview Doesn't Want To Update Records

Apr 4, 2007

I've got a listbox that displays a list of employee's names.  The employee number is the value stored in the listbox.  I then have a vaccinations gridview that displays all the vaccinations received by the selected employee in the listbox.  For some reason, when I click edit and modify a record and then click update it doesn't want to actually update the record.  It just appears to do a postback and redisplay the record without any changes.  My sqldatasource control is configured as follows: SelectCommand="SELECT * FROM [tblVaccinations] WHERE ([EmpNum] = @EmpNum)" @empnum = mylistbox.selectedvalue the update command is as follows:  UpdateCommand="UPDATE [tblVaccinations] SET [EmpNum] = @EmpNum, [VacType] = @VacType, [VacIssueDate] = @VacIssueDate, [VacExpDate] = @VacExpDate, [VacInstitution] = @VacInstitution WHERE [VaccinationNum] = @VaccinationNum"   

View 13 Replies View Related

Qestion About SQLDataSource, Gridview, And Update Panel

Jun 4, 2008

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 7 Replies View Related

GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)

Mar 9, 2006

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 4 Replies View Related

Gridview Button For Calling Sqldatasource.update Fails

Aug 1, 2007

<!-- 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 %>' />&nbsp;
                   
<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>&nbsp;
                   
</ItemTemplate>
               
</asp:TemplateField>
            </Columns>
        </asp:GridView>
        </div>
    </form>
</body>
</html>

 

View 1 Replies View Related

LinqDataSource && GridView: Update Fails (no Rows Affected)

Nov 7, 2007

Hi,
Using VS.NET 2008 Beta2, and SQL Server 2005.
I have a gridview bound to a linq data source, and when trying to update a row, I get an exception that no rows were modified.
The query generated is:
 UPDATE [dbo].[package]
SET [owner_id] = @p5
WHERE ([package_id] = @p0) AND ([title] = @p1) AND ([directory] = @p2) AND ([owner_id] = @p3) AND ([creation_date] = @p4)
-- @p0: Input Int32 (Size = 0; Prec = 0; Scale = 0) [20006]
-- @p1: Input String (Size = 22; Prec = 0; Scale = 0) [Visual Studio.NET 2005]
-- @p2: Input String (Size = 26; Prec = 0; Scale = 0) [MSI_Visual_Studio.NET_2005]
-- @p3: Input Int32 (Size = 0; Prec = 0; Scale = 0) [10000]
-- @p4: Input DateTime (Size = 0; Prec = 0; Scale = 0) [11/07/2007 12:00:00 a.m.]
-- @p5: Input Int32 (Size = 0; Prec = 0; Scale = 0) [10001]
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.20706.1

 
If I run it manually on sql server, it fails until the directory column is removed. The type is varchar(50), with a uniqueness constraint. However, this is same type as the title column, which doesn't have this problem.
Thanks,
Jessica

View 5 Replies View Related

Issue With Getting Values From Child Controls In A Gridview, To Use For The Update Using A SQLDataSource Control

Nov 21, 2006

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>
&nbsp;<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 1 Replies View Related

Unable To Update Or Delete GridView Entries... Must Declare The Scalar Variable @ID1.

Jan 22, 2007

Hello,
 I am having issues and can't see any errors in my code! When attempting to delete a table entry from my SQL database, I get the error "Must declare the scalar variable "@ID1"." even though I declare it as a parameter in my code! Can anyone see an issue with my code below?1 <asp:GridView ID="GridView1" runat="server" AllowSorting="True"
2 DataSourceID="SqlDataSource1" AutoGenerateColumns="False" OnSorted="GridView1_Sorted">
3 <Columns>
4 <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
5 <asp:BoundField DataField="column1" HeaderText="CO" SortExpression="column1" />
6 <asp:BoundField DataField="column2" HeaderText="Network" SortExpression="column2" />
7 <asp:BoundField DataField="column3" HeaderText="C/S/T" SortExpression="column3" />
8 <asp:BoundField DataField="column4" HeaderText="Date Received" SortExpression="column4" DataFormatString="{0:d}" HtmlEncode="False" />
9 <asp:BoundField DataField="DESCRIPTION" HeaderText="Description" SortExpression="DESCRIPTION" />
10 <asp:BoundField DataField="column5" HeaderText="In Service Date" SortExpression="column5" DataFormatString="{0:d}" HtmlEncode="False" />
11 <asp:BoundField DataField="REMARKS" HeaderText="Remarks" SortExpression="REMARKS" />
12 <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
13 SortExpression="ID" />
14 </Columns>
15 </asp:GridView>
16 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConduitConnectionString %>"
17 SelectCommand="SELECT [ID], [CO/Area] AS column1, [NW #] AS column2, [C/S/T] AS column3, [DATE REC'D] AS column4, [DESCRIPTION], [I/S DATE] AS column5, [REMARKS] FROM [Inspector Workload] WHERE ([Inspector Name] = @Inspector_Name) ORDER BY [CO/Area], [DATE REC'D]" DeleteCommand="DELETE FROM [Inspector Workload] WHERE (ID = @ID1)" UpdateCommand="UPDATE [Inspector Workload] SET [CO/Area] = @column1, [NW #] = @column2, [C/S/T] = @column3, [DATE REC'D] = @column4, [DESCRIPTION] = @DESCRIPTION, [I/S DATE] = @column5, [REMARKS] = @REMARKS WHERE ([ID] = @ID1)">
18 <SelectParameters>
19 <asp:QueryStringParameter Name="Inspector_Name" QueryStringField="Name" Type="String" />
20 </SelectParameters>
21 <DeleteParameters>
22 <asp:Parameter Name="ID" Type="Int32" />
23 </DeleteParameters>
24 <UpdateParameters>
25 <asp:Parameter Name="column1" Type="String" />
26 <asp:Parameter Name="column2" Type="Double" />
27 <asp:Parameter Name="column3" Type="String" />
28 <asp:Parameter Name="column4" Type="DateTime" />
29 <asp:Parameter Name="DESCRIPTION" Type="String" />
30 <asp:Parameter Name="column5" Type="DateTime" />
31 <asp:Parameter Name="REMARKS" Type="String" />
32 <asp:Parameter Name="ID" Type="Int32" />
33 </UpdateParameters>
34 </asp:SqlDataSource>
Thanks!Rob.

View 8 Replies View Related

GridView Based On SQLServerDataSource Using A Select Union Statement, Impacts On Update And Insert?

Jan 3, 2006

I have a GridView dispalying from a SQLServerDataSource that is using a SQL Select Union statement (like the following):

SELECT    FirstName,    LastNameFROM    MasterUNION ALLSELECT    FirstName,    LastNameFROM    CustomORDER BY    LastName,    FirstName
I am wondering how to create Update and Insert statements for this SQLServerDataSource since the select is actually driving from two different tables (Master and Custom).  Any ideas if or how this can be done?  Specifically, I want the Custom table to be editable, but not the Master table.  Any examples or ideas would be very much appreciated!
Thanks,
Randy

View 5 Replies View Related

Want Error Message To Appear When No Database Results Were Returned In GridView, Also Other GridView Issues.

Jun 12, 2008

Hi, I am seeking a hopefully easy solution to spit back an error message when a user receives no results from a SQL server db with no results. My code looks like this What is in bold is the relevant subroutine for this problem I'm having.   Partial Class collegedb_Default Inherits System.Web.UI.Page Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click SqlDataSource1.SelectCommand = "SELECT * FROM [college_db] WHERE [name] like '%" & textbox1.Text & "%'" SqlDataSource1.DataBind() If (SqlDataSource1 = System.DBNull) Then no_match.Text = "Your search returned no results, try looking manually." End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load SqlDataSource1.SelectCommand = "SELECT * FROM [college_db] ORDER BY [name]" SqlDataSource1.DataBind() End Sub Protected Sub reset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles reset.Click SqlDataSource1.SelectCommand = "SELECT * FROM [college_db] ORDER BY [name]" SqlDataSource1.DataBind() End SubEnd Class  I'm probably doing this completely wrong, I'm a .net newb. Any help would be appreciated. Basically I have GridView spitting out info from a db upon Page Load, but i also have a search bar above that. The search function works, but when it returns nothing, I want an error message to be displayed. I have a label setup called "no_match" but I'm getting compiler errors. Also, next to the submit button, I also have another button (Protected sub reset) that I was hoping to be able to return all results back on the page, similar to if a user is just loading the page fresh. I'd think that my logic would be OK, by just repeating the source code from page_load, but that doens't work.The button just does nothing. One final question, unrelated. After I set this default.aspx page up, sorting by number on the bottom of gridview, ie. 1,2,3,4, etc, worked fine. But now that paging feature, as long with the sorting headers, don't work! I do notice on the status bar in the browser, that I receive an error that says, "error on page...and it referers to javascript:_doPostBack('GridView1, etc etc)...I have no clue why this happened. Any help would be appreciated, thanks! 

View 2 Replies View Related

Hw 2 Use Creteria Sum Filter In Update Statement?

Sep 4, 2007

Dear all,

M new to SQL Query, i have some update query code that i run have something wrong. It's the following:

update prod_ticket
set prod_ticket.complete_date = '5000/01/01'
FROM prod_ticket INNER JOIN
prod_ticket_hdr ON prod_ticket.lay_id = prod_ticket_hdr.lay_id INNER JOIN
ms_employee ON prod_ticket.employee_no = ms_employee.employee_no INNER JOIN
ms_department ON ms_employee.department_no = ms_department.department_no INNER JOIN
prod_work ON prod_ticket.work_no = prod_work.work_no AND prod_ticket_hdr.prod_no = prod_work.prod_no
WHERE (prod_ticket.complete_date BETWEEN CONVERT(DATETIME, '2007-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2007-08-31 00:00:00', 102)) AND
(prod_work.piece_rate / 10)='0' and prod_ticket.employee_no='50502' and (SUM(prod_ticket.complete_qty))<'30'

I knew that the wrong code is the (SUM(prod_ticket.complete_qty))<'30' because if i delete this condition then the query was ok. Could u please help me to correct the query code for me. really really much appriciated.

View 4 Replies View Related

Retrieve Data From The Gridview

Jun 19, 2006

i need to retrieve data from a particular field of the gridview according to the selected row to stored it into session .....what i had done so far as following: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)        DetailsView1.PageIndex = GridView1.SelectedIndex        Session.Add("receiverName", GridView1.??????)            End Sub????? is the part i am not sure what to code.... i tried different method by seems to have problem of convertion.

View 1 Replies View Related

Default Data Value In Gridview?

Jun 28, 2006

Hi, I am trying to set a default value for a date field in my update parameters:When I try an update with the DefaultValue="<% Now %>", I get this error:"String was not recognized as a valid DateTime."The updates work fine if no default value is set and it also works ok if I change the default value to a set string, such as "6/24/06".  I've tried using different data sources and datasets, but no luck.Anyone have any ideas on this?Thanks! <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db1ConnectionString %>"
ProviderName="<%$ ConnectionStrings:db1ConnectionString.ProviderName %>" SelectCommand="SELECT [ID], [Name], [Date] FROM [Table1]" DeleteCommand="DELETE FROM [Table1] WHERE [ID] = ?" InsertCommand="INSERT INTO [Table1] ([ID], [Name], [Date]) VALUES (?, ?, ?)" UpdateCommand="UPDATE [Table1] SET [Name] = ?, [Date] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Date" Type="DateTime" DefaultValue="<% Now() %>" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Date" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Date" HeaderText="Date" ReadOnly="true" SortExpression="Date" />
</Columns>
</asp:GridView> 

View 3 Replies View Related

Refreshing Data In GridView

Sep 18, 2006

Hi,I’m new to SQL Express, but I have created a table and a stored proc to populate it.I have dragged the table into a form so I can view the data in a GridView.I have added a button to add new rows to the table. All the above works fine, except when I hit add, the data gets added, but the GridView doesn’t update and show the new data.  Is there some code I can add to the add button that also refreshed the GridView? ThanksMike

View 2 Replies View Related

Gridview && SQL Data Source

Jul 22, 2007

I have a few Stored procedures that return values, some need parameters passing and others don't.
Up to now to access that data in a Web App I have called this procedure using VB after seting up a data block etc.
However I notice that the Web Developer express edition has some tools that look like they should help. I have used the in-built tools to create a SQL data source linked to a details view.  I then specified that this should connect to my database (sql2005 hosted) and then specified Custom SQL or Stored procedure.
From the drop down I can then select the SP that purely returns values.   When I try to test this query I get an error to say that the query did not return any data tables.
Is there a way to get values returned from a SP in this way?
Regards
Clive

View 5 Replies View Related

Sql Data Dependency With GridView

Apr 3, 2008

 Hi,I want to add Sql  data dependency in GridView.  Whenever any changes in database, same will be reflected in Grid. but this should work in both Sql server 2000 and sql server 2005. And when we click on "Pause" button it should stop refreshing. 


 


 


 


PAUSE




Index


First name


Last Name


Address




1


Xyz


Abc


Asdf, asdf




2


Pqr


Asd


Sdsa, asad




 Is there any way to fulfill this kind of requirement? Please suggest me optimal solution to do this.Regards,Mustakim Mansuri 

View 1 Replies View Related

Multiple Data Controls In Gridview

Nov 28, 2007

one of my webpages uses the following sql query to allow the user to search through the database and present the qualifying data in gridview:
 SELECT * FROM [Table1] WHERE ([comments] LIKE '%' + ? + '%')
how could i expand this so that the user can also search through the database but instead by searching through another column such as [type]?
thanks in advance

View 11 Replies View Related

How To Use Xml Data From A Sqlserver Table In A Gridview

Jan 6, 2008

I have a products table in a Sql Server 2005 database.  One of the fields contains the products attributes in xml.  The most commonly used attribute is color.  An element of color is inventory.  This is the only way I could think of to maintain inventory numbers of each color of each product using someone else's (opensource) code.  An example of an attribute field would be <?xml version="1.0"?> <ArrayOfAttribute
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Attribute>
<Name>Color</Name> <Description>Shown in
Black</Description> <Selections> <AttributeSelection>
<FormattedValue>483 - Black</FormattedValue> <Value>483 -
Black</Value> <Inventory>25</Inventory>
</AttributeSelection> <AttributeSelection> <FormattedValue>484
- Lt. Tan</FormattedValue> <Value>484 - Lt. Tan</Value>
<Inventory>15</Inventory> </AttributeSelection>
<AttributeSelection> <FormattedValue>485 -
Pink</FormattedValue> <Value>485 - Pink</Value>
<Inventory>17</Inventory> </AttributeSelection>
</Selections> <SelectionType>SingleSelection</SelectionType>
</Attribute> </ArrayOfAttribute> How can I read this into the gridview control so that it makes sense to the user?Diane 

View 5 Replies View Related

Display Data From A Database Without Using Gridview Etc.

Mar 19, 2008

I have a webform that I am wanting to display data from a database. Right now I am using the gridview but for future purposes when it comes to maintenance what would be the easiest way to do updates? For example, if I add a new record into the database I would like the webform to automatically update itself to show all the records including the new record I added. Do I need to use a "table" and somehow connect it to a database? Do any stored procedures need to be created? Suggestions/ideas/codes help help help would be verrrry much appreciated!!! Also I am using MS Server 2003 and C# as the programming language. Thank you!!!!

View 9 Replies View Related

Changing Format Of Data In Gridview Using VB

Mar 24, 2008

Hello all,
I am trying to modify the output of a SELECT statement in a VB asp.net page that pulls data from a SQL DB. I only need to modify one column in the gridview, but I'm having some issues.
Here is the situation:SELECT     TOP 24 ID, RecID, Timestamp, Answered, Holds, Dropped, Waits, Voicemail, Busied, LiveWaitsFROM         mTrafficORDER BY Timestamp DESC
The Timestamp column returns a number value (i.e. 564566).In terms of a date, 564566 doesn't mean anything to the user, so I need to convert this number into a recognizable and accurate date.
The formula I need to implement is Timestamp/1440 - 1
The following SELECT statement returns the number as a date, but makes all records the same date:
SELECT     TOP 24 ID, RecID, Convert(datetime, Timestamp/1440 + 1) as Timestamp, Answered, Holds, Dropped, Waits, Voicemail, Busied, LiveWaitsFROM         mTrafficORDER BY Timestamp DESC
What do I need to do to implement this function dynamically into my gridview?
Thanks in advance!
 
Chris

View 2 Replies View Related

Display Data In A Gridview In A Little Diiferent Way

Apr 25, 2008

Good Day, Please help me, I have a database that looks like this, Building No.        Floor No.        Room No.        Customer Name            Appliances          Appliances Codea                        1                    01                    John                            TV                    12a                        1                    02                             //up tob                        20                  10                    james                       Ref.                       22b                        20                  10                    joe                           Microwave             15 //and soon so if you would notice some rooms are vacant, as it usually happens, the buildings, floors and rooms are fixed except for the customers and the appliances. so at first i made this gridview and display this data in this manner:Customer Location (Building + floor)           total rooms         Used Rooms         Available rooms       A1                                                             2                  1                              1       B2010                                                        2                  2                              0 so if you would look at the table above, it just SUM up all tenants in a specific Location then Group it by Customer location,but i need to add the appliances in a different format like this: Customer Location (Building + floor)           total rooms         Used Rooms         Available rooms            TV         Ref            Microwave
       A1                                                       
     2                  1                              1                         tick
       B2010                                                  
     2                  2                              0                                       tick               tick so this is what i need to show, i already have done the first table (w'o appliances) but how can i make this second table?? please help me, SALAMAT PO.,Thanks  

View 3 Replies View Related

Delete Data From GridView And ObjectDataSource

Mar 11, 2006

The function that is supposed to delete a row, is not working. The function is called, and the windows is refreshed, but the row is not deleted.Can anyone see anything wrong with this code:public static void DeleteBlog(int original_BlogID) { string insertCommand = "DELETE FROM Blog WHERE BlogID = @BlogID"; SqlConnection myConnection = new SqlConnection(Blog.ConnectionString); SqlCommand command = new SqlCommand(insertCommand, myConnection); command.Parameters.Add(new SqlParameter("@BlogID", original_BlogID)); myConnection.Open(); command.ExecuteNonQuery(); myConnection.Close();}

View 3 Replies View Related

Why Can't I Enable Editing On A Gridview That Gets It's Data From A View Through An SqlDataSource?

Nov 22, 2007

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 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved