How To Create A Update Button To Update Two SqlDataSource Controls?

May 10, 2006

I want to update two tables in one page. So I created two FormView bound on two SqlDataSource controls, and I create a Update button on the bottom of page. And I writen some codes as below:

btnUpate_Click(object sender, EventArgs e)
{

   sqlDataSource1.Update();

   sqlDateSource2.Update();
}

But, the records haven't updated.

In SqlDataSource2_Updating() function, I found all the parameters is null.

So, how to modify my code to do it.

 

Zhang

View 2 Replies


ADVERTISEMENT

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

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

Porting VB 6 Data Controls To Use SqlDatasource Controls - Please Help!!!!

May 9, 2007

Hi,  I am porting a massive VB6 project to ASP.net 2005.  Most of the code is fine, however because the original developers used lots of data controls and my own time restrictions I thought to replicate the functionality by using Sqldatasource controls instead. 
 These data controls are bound to DBtruegrids.   The project has has lots of code like...
 AdodcOrders.Recordset.RecordCount > 0 or  If AdodcOrders.Recordset.EOF  or  AdodcOrders.Recordset.MoveNext()  or
AdodcDetail.Recordset!FieldName
The problem is the sqldatasource control doesn't have a recordset/dataset property which I can access and manipulate, or does it?  What should I do to get round these?  The project has thousands of lines like this in so its not feasible to rewrite it (although if I could I would!).
 Any suggestions please gratefully appreciated.
many thanks
mike

View 1 Replies View Related

Trying To Execute An Update Query From A Button

Jun 16, 2006

I've got a sqldatasource with a update query in it.  Now I'm trying to execute that query on button click.  How do I go about doing so?
 
Here's my ASPX code:
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Data_Verification_Editor.aspx.vb" Inherits="Core_Data_Verification_Editor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Verification Editor</title>
</head>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDS_Valid" runat="server"
ConnectionString="<%$ ConnectionStrings:Test%>"
SelectCommand="Data_Validation_sp" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
<asp:SqlDataSource ID="Test" runat="server"
ConnectionString="<%$ ConnectionStrings:Test%>"
UpdateCommand="UPDATE [Data_Valid_Current_tbl] SET ID = '@selected_id', SET Title = '@selected_text' WHERE PrimID = '1'">
<UpdateParameters>
<asp:ControlParameter Name="selected_id" ControlID="Data_Ver_ddl" PropertyName="SelectedValue" />
<asp:ControlParameter Name="selected_text" ControlID="Data_Ver_ddl" PropertyName="SelectedText" />
</UpdateParameters>
</asp:SqlDataSource>
<table style="width: 320px; background-color: menu; border-right: menu thin ridge; border-top: menu thin ridge; border-left: menu thin ridge; border-bottom: menu thin ridge; left: 3px; position: absolute; top: 3px;">
<tr>
<td colspan="2" style="font-family: Tahoma; font-size: 10pt;">
Testing:<br />
</td>
</tr>
<tr>
<td colspan="2">
<asp:DropDownList ID="Data_Ver_ddl" runat="server" DataSourceID="SqlDS_Valid" DataTextField="Title"
DataValueField="ID" style="width: 100%; height: 24px; background: gold">
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width:50%">
<asp:Button ID="Submit_btn" runat="server" Text="Submit" Font-Bold="True"
Font-Size="8pt" Width="100%" />
</td>
<td style="width:50%">
<asp:Button ID="Done_btn" runat="server" Text="Done" Font-Bold="True"
Font-Size="8pt" Width="100%" />
</td>
</tr>
</table>
</form>
</body>
</html>
 

View 1 Replies View Related

Why Is This SQL UPDATE Query Not Updating When This Code Is Used Under Button.click.

Mar 20, 2008

Why is this SQL UPDATE query not updating when this code is used under button.click.

Dim ListingID As String = Request.QueryString("id").ToString
Dim sqlupdate As String = "UPDATE Listings SET PlaceName = '" & PlaceName.Text & "', Location = '" & Location.SelectedValue & "', PropertyType = '" & PropertyType.SelectedValue & "', Description = '" & Description.Text & "', Price = '" & Price.Text & "' WHERE ListingID ='" & ListingID & "'"
Dim con As New SqlConnection(ListingConnection)
Dim cmd As New SqlCommand(sqlupdate, con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()

View 12 Replies View Related

Dynamically Binding Button And Controls On Table Rows.

Jun 15, 2007

Hi,



I am new to .NET world. I am using visual studio express.

I am developing website using ASP.NET and C#.



I want to add buttons dynamically on a table row on my web page.



For this I have written this code in "example.aspx" file







<asp:Table ID="tblExample" GridLines="Both" BorderWidth="1" runat="server" >



</asp:Table>







In my corresponding "example.aspx.cs" file i have written









TableRow tr = new TableRow();

.....................

.....................



TableCell tc3 = new TableCell();

tc3.Width = 120;

Button bt = new Button();

bt.Text = btnStop.Text;

bt.Width = 120;

bt.CommandArgument = lrs.IpAddress + ":" + lrs.PortNo;

bt.Click += new EventHandler(cmdStop_Click);

tc3.Controls.Add(bt);

tr.Cells.Add(tc3);



tblExample.Rows.Add(tr);













In my EventHandler "cmdStop_Click" I am trying to perform some action but on that particular row's data.



My page is also reloading after every 5 secs.



After clicking a button in a row, when page refreshes, I am getting this message in popup error message. also that entry is ommited(as per code in EventHandler)

______________________________________________________

"The Page cannot be refreshed without resending the information.

Click retry to resend the information again.

or click Cancel to return to the page that you were trying to view"



resetButton cancelButton

_______________________________________________________





How to bind that button to particular row so that when I click on a button the action should be performed on that particular row's data.







Thanks

View 1 Replies View Related

Select Statement (Advvance Button Insert, Update, Deltete

May 6, 2007

Hello All
I have had asked the same question in another post, i didnt get answer to it i might have had asked it wrongfully
 
Soo the question is:   When creating a SQLDataSource in the wizard  you get to the pont where you select the option . It says that by using this datasource you can select to update delete and insert. So my question is if i am creating a select statement to reterieve the data from the Table, then what does it do it do if my intention is to only reterie the data. Or what is the other way that it could be helpful to me ??
 
thanks all I hope it make sence, if not I wrill write another post to bring step by step info into it.
 

View 1 Replies View Related

Sqlcommand And Visual Studio Net 2003 Code To Update A Record With A Click Of Button.

Sep 1, 2006

Hello to everyone,  I have this problem If I use this code when I try to update a record in my sql database It does not do anything. This is the code.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim myconn As New SqlConnection("Data Source=.;Initial Catalog=SistemaIntegral; user id=sa")        Dim mycmd As New SqlCommand("presup", myconn)        mycmd.CommandType = CommandType.StoredProceduremycmd.parameters.Add(New SqlParameters("@txtClave", SqlDbtype.int,4)).Value=txtClave.textmycmd.parameters.Add(New SqlParameters("@txtForig", SqlDbtype.varchar,50)).Value=txtFOrig.textmycmd.parameters.Add(New SqlParameters("@txtFmod", SqlDbtype.varchar,50)).Value=txtFmod.textmycmd.parameters.Add(New SqlParameters("@txtFeje", SqlDbtype.varchar,50)).Value=txtFeje.textmycmd.parameters.Add(New SqlParameters("@txtPorig", SqlDbtype.varchar,50)).Value=txtPorig.textmycmd.parameters.Add(New SqlParameters("@txPmod", SqlDbtype.varchar,50)).Value=txtPmod.textmycmd.parameters.Add(New SqlParameters("@txtPeje", SqlDbtype.varchar,50)).Value=txtPeje.text mycmd.parameters.Add(New SqlParameters("@txtClave", SqlDbtype.int,4)).Value=txtClave.text        myconn.Open()        mycmd.ExecuteNonQuery()        myconn.Close()        mycmd.Dispose()        myconn.Dispose()    End Sub  This is the code for the procedure called "presup" in SQL 2000 Server.CREATE PROCEDURE [presup](@txtClave [int],@txtForig [varchar](50),@txtFmod [varchar](50),@txtFeje [varchar](50),@txtPorig [varchar](50),@txtPmod [varchar](50),@txtPeje [varchar](50),@txtIdPresupuesto [int])as Update [Presupuesto]Set [IdClave]=@txtClave,[orig]=@txtForig,[moda]=@txtFmod,[ejer]=@txtFEje,[origr]=@txtPorig,[modar]=@txtPmod,[ejerr]=@txtPejeWhere ([IdPresupuesto]=@txtIdPresupuesto)GO When I click the Update button of my webform it does not do anything. Please Help me I am new to Visual Studio.Net 2003. (2 weeks ago I started using Visual Studio) 

View 1 Replies View Related

Update Not Working In An SQLDataSource

Sep 6, 2006

I'm new to ASP and ASP.NET so I used the Wizards in Visual Web Deverlopment Express 2005 to build the following code:<asp:DetailsView ID="DetailsView" runat="server" DataSourceID="TracksDataSource"
Height="50px" Width="125px" AutoGenerateEditButton="True" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="pk_trackID" HeaderText="pk_trackID" ReadOnly="True" SortExpression="pk_trackID" />
<asp:BoundField DataField="trackName" HeaderText="trackName" SortExpression="trackName" />
<asp:BoundField DataField="trackPath" HeaderText="trackPath" SortExpression="trackPath" />
<asp:BoundField DataField="lyrics" HeaderText="lyrics" SortExpression="lyrics" />
</Fields>
</asp:DetailsView>

<asp:SqlDataSource ID="TracksDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="SELECT * FROM [Tracks] WHERE ([pk_trackID] = @pk_trackID)" UpdateCommand="UPDATE [Tracks] SET [trackName] = @trackName, [trackPath] = @trackPath, [lyrics] = @lyrics WHERE [pk_trackID] = @pk_trackID" >
<UpdateParameters>
<asp:Parameter Name="trackName" Type="String" />
<asp:Parameter Name="trackPath" Type="String" />
<asp:Parameter Name="lyrics" Type="String" />
<asp:Parameter Name="pk_trackID" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="TracksListBox" Name="pk_trackID" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>  However, when I click Edit, change something, and then Update it doesn't update the database. However, if I remove the DataField bindings and use the AutoGenerateRows feature it works fine.

View 7 Replies View Related

Using XML As An Update Parameter In A SqlDataSource?

Nov 6, 2006

One of the requirements of the UpdateParameters for a GridView I'm building is that the fields that are being edited via EditItemTemplates are passed back to the UpdateParameter as XML. How would I go about combining the fields from the GridView/EditItems into an XML string that I can set as an asp:Parameter?
Thanks.

View 1 Replies View Related

OldValuesParameterFormatString SqlDataSource Update

Mar 15, 2007

OK guys, I'm sure I'm doing something stupid here but after 2 days I find myself extremely frusted... Any help would be appreciated
I'm tring to write an update procedure for an SqlDataSource control that will allow me to chage the primary key values of a record in the table. Everything seems to work fine with the exception of obtaining the old values (the primary key before its changed by the end user) during the update. I've read several articles on the web an in the forums on this topic. Much of it has to do with the .NET beta version alteration from "original_{0}" to "{0}". I believe those conversations do not describe my problem.
Anyhow, onto some source code. Here's the ASP source code for a grid view and sql data source. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="productName,productURL" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="productName" HeaderText="productName" ReadOnly="True"
SortExpression="productName" />
<asp:BoundField DataField="productURL" HeaderText="productURL" ReadOnly="True" SortExpression="productURL" />
<asp:BoundField DataField="productSupportURL" HeaderText="productSupportURL" SortExpression="productSupportURL" />
<asp:BoundField DataField="description" HeaderText="description" SortExpression="description" />
<asp:BoundField DataField="modified" HeaderText="modified" SortExpression="modified" />
<asp:BoundField DataField="userid" HeaderText="userid" SortExpression="userid" />
<asp:BoundField DataField="useridDomain" HeaderText="useridDomain" SortExpression="useridDomain" />
<asp:BoundField DataField="sortOrder" HeaderText="sortOrder" SortExpression="sortOrder" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SBAAdminConnectionString1 %>"
DeleteCommand="DELETE FROM [homePageList] WHERE [productName] = @old_productName AND [productURL] = @old_productURL"
InsertCommand="INSERT INTO [homePageList] ([productName], [productURL], [productSupportURL], [description], [modified], [userid], [useridDomain], [sortOrder]) VALUES (@productName, @productURL, @productSupportURL, @description, @modified, @userid, @useridDomain, @sortOrder)"
ProviderName="<%$ ConnectionStrings:SBAAdminConnectionString1.ProviderName %>"
SelectCommand="SELECT [productName], [productURL], [productSupportURL], [description], [modified], [userid], [useridDomain], [sortOrder] FROM [homePageList]"
UpdateCommand="UPDATE homePageList SET productSupportURL = @productSupportURL, description = @description, modified = @modified, userid = @userid, useridDomain = @useridDomain, sortOrder = @sortOrder, productName = @productName, productURL = @productURL WHERE (productName = @original_productName) AND (productURL = @original_productURL)" OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp:Parameter Name="old_productName" Type="String" />
<asp:Parameter Name="old_productURL" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="modified" Type="DateTime" />
<asp:Parameter Name="userid" Type="String" />
<asp:Parameter Name="useridDomain" Type="String" />
<asp:Parameter Name="sortOrder" Type="Single" />
<asp:Parameter Name="productName" Type="String" />
<asp:Parameter Name="productURL" Type="String" />
<asp:Parameter Name="productSupportURL" Type="String" />
<asp:ControlParameter ControlID="GridView1" Direction="InputOutput" Name="original_productName"
PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Direction="InputOutput" Name="original_productURL"
PropertyName="SelectedValue" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="productName" Type="String" />
<asp:Parameter Name="productURL" Type="String" />
<asp:Parameter Name="productSupportURL" Type="String" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="modified" Type="DateTime" />
<asp:Parameter Name="userid" Type="String" />
<asp:Parameter Name="useridDomain" Type="String" />
<asp:Parameter Name="sortOrder" Type="Single" />
</InsertParameters>
</asp:SqlDataSource>I added a text box for every field in the grid to the form and update the fields when the user selects a record in the GridView. I then added an Update button to the form and tied the event to this procedure:  Protected Sub bUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bUpdate.Click
'if the user has not entered key fields!
If missingKeyFields() Then
Exit Sub

End If

Dim count, so As Integer
Dim uDomain, uid As String

'parse out the user id and domain.
Try
If HttpContext.Current.User.Identity.Name = "" Then
uid = "unknow"
uDomain = "unknown"

Else
uid = HttpContext.Current.User.Identity.Name
uid = uid.Substring(uid.IndexOf("") + 1)
uDomain = uid.Substring(0, uid.IndexOf("") - 1)

End If

Catch ex As Exception
uid = "unknow"
uDomain = "unknown"

End Try

'fill in the parameters
'@productName, @productURL, @productSupportURL, @description, @modified, @userid, @useridDomain, @sortOrder
Me.SqlDataSource1.UpdateParameters.Item("productName").DefaultValue = Me.tbProductName.Text
Me.SqlDataSource1.UpdateParameters.Item("productURL").DefaultValue = Me.tbProductURL.Text
Me.SqlDataSource1.UpdateParameters.Item("productSupportURL").DefaultValue = Me.tbProductSupportURL.Text
Me.SqlDataSource1.UpdateParameters.Item("description").DefaultValue = Me.tbProductDescription.Text
Me.SqlDataSource1.UpdateParameters.Item("modified").DefaultValue = Now
Me.SqlDataSource1.UpdateParameters.Item("userid").DefaultValue = uid
Me.SqlDataSource1.UpdateParameters.Item("useridDomain").DefaultValue = uDomain
Me.SqlDataSource1.UpdateParameters.Item("sortOrder").ConvertEmptyStringToNull = True

If Integer.TryParse(Me.tbSortOrder.Text, so) Then
Me.SqlDataSource1.UpdateParameters.Item("sortOrder").DefaultValue = so

Else
Me.SqlDataSource1.UpdateParameters.Item("sortOrder").DefaultValue = ""

End If

'insert the record.
count = Me.SqlDataSource1.Update()
Me.lCommandInfo.Text = count.ToString + " record was updated."

End Sub
 The net result of the procedure is the message "0 record was updated." when I select a record in the gridView and then edit the "productName" field and click Update.
In an attempt to trace down the problem I added this code: Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating

Message.Text = e.Command.CommandText
Message.Text += "<br>"
For lp As Integer = 0 To e.Command.Parameters.Count - 1
Message.Text += e.Command.Parameters(lp).ParameterName + "=" + e.Command.Parameters(lp).Value
Message.Text += "<br>"

Next

End Sub
The message label displays the following text:UPDATE homePageList SET productSupportURL = @productSupportURL, description = @description, modified = @modified, userid = @userid, useridDomain = @useridDomain, sortOrder = @sortOrder, productName = @productName, productURL = @productURL WHERE (productName = @original_productName) AND (productURL = @original_productURL)
@description=interesting!
@modified=3/15/2007 4:07:31 PM
@userid=unknow
@useridDomain=unknown
@sortOrder=
@productName=ok22
@productURL=http
@productSupportURL=http
@original_productName=ok
@original_productURL=ok
Notice how the "@original_productURL" has the same value as the "@original_productName"? This should not be the case. The @original_productURL should equal "http" since I didn't update the field's value. It seems like the second field of the primary key is not getting updated or passed to the @original_productURL parameter. Since .NET handles the @original_{0} parameters I don't know why the field isn't being properly updated.
Any thoughts on how to track down the root cause of my problem... Or better yet any thoughts on a work around to my problem?
Thanks,Johnny

View 5 Replies View Related

Need Help With SQLDataSource Update Parameter

Jun 14, 2007

I need to know how to setup the ControlParameter for a template control in my Gridview? I have a datepicker in my template and I need to know how to refer to it in the ControlParameter of the SQLDataSource control.
  <UpdateParameters>
<asp:ControlParameter Name="dp_start" ControlID="bdpPlanStart" PropertyName="SelectedValue" Type="Datetime" />  Here is the template:<asp:TemplateField HeaderText="Start" SortExpression="dp_start">
<ItemTemplate>
<%#DataBinder.Eval(Container, "DataItem.dp_start", "{0:d}")%>
</ItemTemplate>
<EditItemTemplate>
<BDP:BasicDatePicker id="bdpPlanStart" SelectedValue='<%# DataBinder.Eval(Container.DataItem,"dp_start") %>' runat="server" DateFormat="d">
</BDP:BasicDatePicker>
</EditItemTemplate>
</asp:TemplateField>  

View 1 Replies View Related

How To Update SqlDataSource Query

Nov 7, 2007

I am trying to reload an AJAX control without reloading the page.  This question may belong under AJAX,  but I'm not sure if I'm managing the SqlDataSource correctly.  I want to set the SelectCommand to a new SQL statement and refresh the form on the screen.  My code is below.  It doesn't seem to be working.  Do I need to call something else or is this correct and the problem is with that nasty AJAX?SqlDataSource oSqlDataSource1 = (SqlDataSource) oContentPlaceHolder1.FindControl("SqlDataSource1");oSqlDataSource1.SelectCommand = "SELECT * FROM WorkHistory WHERE WorkHistoryID = " + sWorkHistoryID;oSqlDataSource1.Select(DataSourceSelectArguments.Empty);

View 2 Replies View Related

Two Update Commands For A SqlDataSource?

Jan 16, 2008

Is there a way to have two sql update commands so I can use both during an update depending on which row it is?

View 1 Replies View Related

SqlDataSource Won't Update Table

Feb 8, 2008

I have a number of textboxes in a WizardStep of my CreateUserWizard and I can't update the contents to the database (see below for an example). Any suggestions would be appreciated. Dim txt As TextBox = cuwMoreInfo.FindControl("txtAddress")
srcMoreInfo.UpdateParameters("Address").DefaultValue = DirectCast(txt, TextBox).Text 

View 12 Replies View Related

Sqldatasource Update() Method

Apr 5, 2008

Hi All, 
i want to use sqldatasource with controlparameters.there are some textboxes and a dropdownlist on my page.i can easily insert and delete records on database table by using these controls as controlparameters by sqldatasource insert() and delete() method  but updating  fails.i use try catch block to see the error but no errors found.And also update() method returns 1 that indicates that it worked fine but when i look into the database i see that the record is not updated.i am stucked and surprised.any ideas please?
Thanks
 

View 5 Replies View Related

Sqldatasource Update Problem

Apr 18, 2008

I just want to update a single file on the table with the content of a text box

the sql statement is update GAMME set newvaleur=@newvaleur where product_ID=old_product_ID

on sqldatasource1 updating I wrote

E.COMMAND.PARAMETERS("@newvaleur").value=....
e.command.parameters("old_product_id").value=....

the thing is it doesn't work, I don't think the line with the old_product_id is ok but I don't know how to do it...

View 4 Replies View Related

Help With UPDATE With SqlDataSource And A Repeater

Jan 15, 2006

Hi,
I have a repeater which i need to build editing capabilities into in a similar way as the GridView, just a little unsure how to tie it together.  Ideally i would like to use a GridView as this would do all of the work for me however it looks like I need to go with the repeater due to the nested nature of the data I am working with.
What is the best way to go about updating the data source from within a repeater?  I have already built the edit interface with some MultiViews in the Repeater control and handling the ItemCommand event, just not sure how to actually update the data source.
Can I still use the SqlDataSource wizard to generate all of the SQL for me?  If so, within the ItemCommand event handler I have the data i want to update back to the database by using the FindControl method and retrieving the Text, but how do i get this data into the SqlDataSource object and update the database?
Are there any samples available which show how to update a datasource using a repeater?
Your help is much appreciated
trenyboy

View 6 Replies View Related

User Controls And Sqldatasource

Nov 19, 2007

I created a user control file with 3 properties. I would like to call this user control in a datalist control in the hosting page and pass the properties from a sqldatasource control. To this end I have a code like below;
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="SELECT [1], [2], [3] FROM [table1]"></asp:SqlDataSource>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView" >
<ItemTemplate>
<uc:kk ID="kk1" runat="server" One='<%# Eval("1") %>' Two='<%# Eval("2") %>' Three='<%# Eval("3") %>' /></ItemTemplate></asp:DataList> I don't get any errors when I run the page, however it won't work as I wish. Only thing that appears in the rows of datalist is "01.01.0001 00:00:00".

View 4 Replies View Related

SQLDataSource Update Using Parameters Not Working

Jul 10, 2006

I'm passing a parameter to a stored procedure stored on my sqlserver, or trying to atleast.  And then firing off the update command that contains that parameter from a button.  But it's not changing my data on my server when I do so.
I'm filling a dropdown list from a stored procedure and I have a little loop run another sp that grabs what the selected value should be in the dropdown list when the page loads/refreshes.  All this works fine, just not sp that should update my data when I hit the submit button.
It's supposed to update one of my tables to whatever the selected value is from my drop down list.  But it doesn't even change anything.  It just refreshes the page and goes back to the original value for my drop down list.
Just to make sure that it's my update command that's failing, I've even changed the back end data manually to a different value and on page load it shows the proper selected item that I changed the data to, etc.  It just won't change the data from the page when I try to.
 
This is what the stored procedure looks like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTER PROCEDURE [dbo].[UPDATE_sp] (@SelectedID int) AS
BEGIN
UPDATE [Current_tbl]
SET ID = @SelectedID
WHERE PrimID = '1'
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And here's my aspx page:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Editor.aspx.vb" Inherits="Editor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Verification Editor</title>
</head>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SQLDS_Fill" runat="server" ConnectionString="<%$ ConnectionStrings:Test %>"
SelectCommand="Current_sp" SelectCommandType="StoredProcedure" DataSourceMode="DataSet">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SQLDS_Update" runat="server" ConnectionString="<%$ ConnectionStrings:Test %>"
SelectCommand="Validation_sp" SelectCommandType="StoredProcedure" DataSourceMode="DataReader"
UpdateCommand="UPDATE_sp" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:ControlParameter Name="SelectedID" ControlID="Ver_ddl" PropertyName="SelectedValue" Type="Int16" />
</UpdateParameters>
</asp:SqlDataSource>
<table style="width:320px; background-color:menu; border-right:menu thin ridge; border-top:menu thin ridge; border-left:menu thin ridge; border-bottom:menu thin ridge; left:3px; position:absolute; top:3px;">
<tr>
<td colspan="2" style="font-family:Tahoma; font-size:10pt;">
Please select one of the following:<br />
</td>
</tr>
<tr>
<td colspan="2">
<asp:DropDownList ID="Ver_ddl" runat="server" DataSourceID="SQLDS_Update" DataTextField="Title"
DataValueField="ID" style="width: 100%; height: 24px; background: gold">
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width:50%;">
<asp:Button ID="Submit_btn" runat="server" Text="Submit" Font-Bold="True"
Font-Size="8pt" Width="100%" />
</td>
<td style="width:50%;">
<asp:Button ID="Done_btn" runat="server" Text="Done" Font-Bold="True"
Font-Size="8pt" Width="100%" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label runat="server" ID="Saved_lbl" style="font-family:Tahoma; font-size:10pt;"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And here's my code behind:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imports System.Data
Imports System.Data.SqlClient
Partial Class Editor
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Saved_lbl.Text = ""
Done_btn.Attributes.Add("OnClick", "window.location.href='Rpt.htm';return false;")
Dim View1 As New DataView
Dim args As New DataSourceSelectArguments
View1 = SQLDS_Fill.Select(args)
Dim Row As DataRow
For Each Row In View1.Table.Rows
Ver_ddl.SelectedValue = Row("ID")
Next Row
SQLDS_Fill.Dispose()
End Sub
Protected Sub Submit_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit_btn.Click
SQLDS_Update.Update()
Saved_lbl.Text = "Thank you. Your changes have been saved."
SQLDS_Update.Dispose()
End Sub
End Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Any help is much appreciated.

View 4 Replies View Related

UPDATE/DELETE Bug In SqlDataSource - Will Microsoft Ever Fix This?

Aug 3, 2006

I'm referring to this bug, which I've seen a lot of people (including me) run into:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93937
Has anyone heard if MS plans to fix this soon?
Thanks

View 3 Replies View Related

Can't Update A Record Using A DetailsView And SqlDataSource

Feb 13, 2007

Hi,I'm trying to create a registration page that I've divided into multiple pages (first page for basic details, next page for address, etc.). I insert the record in the first page, and update it in the other pages. I pass the newly created ID to the other pages using the Page.PreviousPage property.  In the second page, I have the SqlDataSource configured as "SELECT * FROM [Table] WHERE ID = ?", and the UpdateCommand is "UPDATE .... WHERE ID = ?".  In Page_Load, I am updating the SelectCommand to "SELECT ... WHERE ID = " & intID, and the UpdateCommand similarly. The I do a dtlsvw.Databind()But when I go to the next page (the newly created ID is being passed properly), the update doesn't do anything. The new record doesn't contain the values in the detailsview. Can somebody help me out? Thanks,Wild Thing 

View 2 Replies View Related

SQLDataSource: Update 2 Tables With 1 UpdateCommand?

Mar 16, 2007

I have a Gridview (edit enabled), connected to a SQLDataSource.
 SQLDataSource populates the gridview from 1 SelectCommand.
 figure1:
ColumnA | ColumnB | ColumnC
 
I have 2 SQL Server 2005 tables: Table1 and Table2 
Now on my SQLDataSource's UpdateCommand, I want the value of ColumnB to go to Table1's ColumnB, and ColumnC to go to Table2's ColumnC.
How do I do this?
I understand I can't do this with 1 UPDATE-SET sql query. Maybe I can with stored procs or something, but im kinda noobish when it comes to this. How? Thanks

View 1 Replies View Related

Error During SqlDataSource.Update() Instruction

May 29, 2007

Hi, I have such a problem:I try to update (or insert) a row in my table and i fail althought i,ve read many posts here. I.ve created a button and "on_click" event to this button and want that event to update or insert a record in my table. I wrote: protected void selectButton_Click(object sender, EventArgs e)    {        String taskID = projectsGridView.SelectedRow.Cells[0].Text;        usersSqlDataSource.UpdateCommand = "update [Users] set [TaskID]=@task where [UserID]=1";        usersSqlDataSource.UpdateParameters.Add("task", taskID);        usersSqlDataSource.Update();    }  The application creates error in the last line of code (usersSqlDataSource.Update();) and i receive such an error:You have specified that your update command compares all values on SqlDataSource 'usersSqlDataSource', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. For me it looks like there is a problem while setting parameters. Shall i change some properties of the sqlDataSource or GridView? Please help..    

View 2 Replies View Related

Help: Programmatically Update Data From An SQLDataSource (C#)

Jul 3, 2007

ello all
 Would someone be so kind as to save me from getting balder through pulling my hair out.
My aim is to extract data from a database using SQLDataSource, then edit the data and update the database using the SQLDataSource.
I have achieve the problem of retrieving the data from the sqlDataSource:DataView openRemindingSeats = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty);        //Int32 openRemindingSeats = SqlDataSource2.Select(DataSourceSelectArguments.Empty), DataView;
        foreach (DataRowView rowProduct in openReminding)        {            //Output the name and price            lbl_NumOfSeatsLeft.Text = rowProduct["Remaining"].ToString();
        }
Within the sqlDataSource the sql code is as follows:SELECT [refNumber], [refRemaining] FROM [refFlights] WHERE ([refNumber] = @Number)
So at the moment my problems is being able to edit and update data to the same SELECTed data.Thank you for any help that you might have...
SynDrome

View 8 Replies View Related

SQLDataSource.Update Returning Negative Value

Jun 9, 2008

Does anyone know why would SQLDataSource.Update method return a negative value even though its updating records correctly?Its happening with .NET 2.0. 

View 2 Replies View Related

SqlDataSource: Insert, Update And Delete Not Available

Jan 3, 2006

Hello Guys,
 
I’m trying to create a sqlDataSource using the wizard, I can get the select statement, the here clause and the order by clause but when I click on the Advanced button the options to generate the insert, update and delete statements are not available. Does anyone know what am I doing wrong?

View 4 Replies View Related

How To Put New Data Into SqlDataSource Update With Concatenated Key?

Jan 26, 2006

Here is the problem.
I have table such as this
PK selection VARCHARPK selection_choice VARCHAR      show BIT
When I use the sqlDataSource to create an update it creates this.UPDATE lu_selection_choices SET show = @show WHERE (selection = @selection) AND (selection_choice = @selection_choice)
Now this is OK, but when you perform an update and in say a details control you change the selection_choice the value of the parameter @selection_choice is going to be equal to the old data.  So it performs a successful update on show which isn't being changed selection_choice is.
So the questions is.  Is there anyway to tell the update function of the datasource to insert the a new parameter with the SET selection_choice = @SOME NEW PARAM slection_choice?
Thanks,
Darren King
 

View 4 Replies View Related

How To Trigger The Update Command Of The SQLDataSource

Jun 13, 2006

Hi - I'm using .net2, and have a gridview, populated by a SQL Datasource (Edit, Insert, Delete, Select).
Like we all used to do with the datagrid, I've added text boxes into the footer, and a link button, which I'd like to use to fire the Update command.
How do I get the link button to trigger the update command?
Thanks, Mark

View 1 Replies View Related

Can Multiple Selection Controls Be Use With SqlDataSource?

Mar 4, 2007

 NET 2.0 
I am using Visual Studio Express 2005 for database web developement.
I have created a database with 5 tables.  Two are associative tables.
They are
SoftwarePK SoftwareID      Title
SoftwareSolutionFK SoftwareIDFK SolutionID
SolutionPK SolutionID     Title
CategorySolutionFK CategoryFK Solution
Category
PK Category     Title 
Criteria for a search with three sources of input into a SqlDataSource attached to a FormView for paged out. 
The following are the Search Criteria input sources:1) ListBox in Multiple Selection Mode2) CheckBoxList with Mutiple checks posible2) TextBox with key word search in Title.
Each Solution has 0 or many Categories and 0 or many Software.
When the records are entered in the database, the associative information for Categories and Software are populated to filter thereturned values.
In NET  1.1, I would create a search string like the following in code behind by looping through the CheckBoxList and ListBox finally adding the TextBox:
SELECT Solution.SolutionID, Solution.Title FROM SolutionWHERE             Solution.SolutionID IN ('2','3','5')      AND             Solution.Title LIKE '%Math%'
I am unable to update the SelectCommand in the ASPX page.
However, when I use the I have used theSystem.Web.UI.WebControls.SqlDataSources"SelectQuery Builder"I receive the following in the Source for ASPX: <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT Solution.SolutionID, Solution.Title
FROM
Solution INNER JOIN CategorySolution ON Solution.SolutionID = CategorySolution.SolutionID
INNER JOIN SoftwareSolution ON Solution.SolutionID = SoftwareSolution.SolutionID">
<SelectParameters>
<asp:ControlParameter ControlID="CheckBoxList1" DefaultValue="%" Name="CategoryID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="ListBox1" DefaultValue="%" Name="SoftwareID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="txtTitleSearch" DefaultValue="%" Name="Title" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource> I receive duplicate records and not sure if the code generated accesses the Mutiple Selected values in the CheckBoxList1 and ListBox1.Question: 1) If the SelectQuery generator will not access multiple selected values from the CheckBoxList1, how can I use code behind to replaceSelectCommand in the ASPX page?2) What is the best solution for using the CheckBoxList1, ListBox1, and TextBox for filtering my results? Sample code, references to solutions, corrections on logic, a new approach, how to use the wizard correctly would all be greatly appreciated.3) Can Multiple Selection Controls be use with a SqlDataSource SELECT Command?Thanks for your time,Sincerely,Unhistoric

View 2 Replies View Related

Multiple SqlDataSource Controls On A Page

Jun 8, 2007

Thanks for your help.
 I'm just getting into ASP.NET 2.0 and started using the SqlDataSource control to declaritively connect to a database. I was wondering if I have two SqlDataSource controls on one page with two select commands querying the same database, will the that create to seperate instances of opening and closing the connection to the database, or will it open the database once, execute both queries, and then close the connection. It seems that if it creates two separate connections, it would still be more efficient to to connect to the database programmatically using ADO.NET. You would only need to make one trip to the database, pull down all of your data, and then close the connection.
Adrian

View 1 Replies View Related

SqlDataSource Not Allowing Insert, Update And Delete

Jul 4, 2006

i have default.aspx file and i put SqlDataSource into my designer form.when i want to configure SqlDataSource it not allowed my to insert, update and delete only insert is allowed.what is the problem and the solution for this case ...thx

View 1 Replies View Related







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