Need To INSERT SqlDataSource Control When Button Is Clicked

Mar 28, 2007

Ok, this seems really straightforward, but I'm completely lost. 

I created a sqldatasource control that uses an INSERT stored procedure. I can click on test it tests just fine, inserts everything into the database.
Now, I want this sqldatasource control to fire when a button is clicked, but I have no idea how to do this, I looked at the parameters and cant find an execute or anything like that to use. Let me know how to execute this sqldatasource, it'd really help me out. I know you can do EVERYTHING in the code behind file, but I'm rather new to VB and I'm probably gonna save that for another day. Here's what I have now:
basic sqldatasource :
        <asp:SqlDataSource ID="SqlProcDS" runat="server" ConnectionString="<%$ ConnectionStrings:pubsConnectionString %>"
             InsertCommand="ins_test" InsertCommandType="StoredProcedure" SelectCommand="ins_test" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="a" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="TextBox2" Name="b" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="TextBox3" Name="c" PropertyName="Text" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="a" Type="String" />
                <asp:Parameter Name="b" Type="String" />
                <asp:Parameter Name="c" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
in the vb file :
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

 'Somehow execute sqlProcDS here?!

End Sub

View 1 Replies


ADVERTISEMENT

How To Change The Value Of A Column In Sql Server 2005 Database When A Button Is Clicked In Asp.net 2.0?

Nov 22, 2007

hi all,
I have created a table in sql server 2005 as follows:
table name --> sampletest
1.id -->int ,identity,primary key
2. student_name --> varchar(50),not null
2. active --> bit, default value=1
Using vb.net 2005 , i entered names into sampletest. And when i check the table in the sql server 2005 the names are inserted and the active value is 1.
In another page i added a drop down list which bind all the student_name from sampletest and a delete button.
Now when i select a name and click the delete button that respective item's active column should be changed to 0. if any one who knows how to do this please help me..
thanks
swapna.
When i enter names into the student_name it's active state is "true".I do this programmatically using vb.net 2005.  

View 2 Replies View Related

Having Trouble Configuring The SqlDataSource Control's Update And Insert Commands

Jul 24, 2007

I've just finished configuring the SELECT command for the SqlDataSource in my ASP.NET 2.0 web app.  It works fine and runs against a SQL Server 2005 database, using a stored procedure that I've written.
So, then I went to configure the SqlDataSource for the UPDATE and INSERT commands, and I've written two SP's for those as well.  In the designer the second form of the wizard asks for the Select statement.  I've already given that for the SELECT statement in the third form, and I also select the INSERT tab to specify the SP I want to use for inserting data and the UPDATE tab to specify the SP I want to use for updating data.  However, there appears to be no way that I can specify what the parameters are supposed to be for anything other than the SELECT command, through the designer.  Is that correct, or have I missed something?
 

View 11 Replies View Related

SqlDataSource Insert, Update Delete Options Are Dimmed In Configure DataSource Control

Mar 23, 2008

I can select the tables and fields, but when I click on Advanced the Check Box to Create the Commands is not available. they are dimmed out.
Why is this happening, is it a setting that I have missed. Any help is appreciated.

View 1 Replies View Related

Can I Use A SqlDataSource Control Exclusively To Pass Data To A Stored Procedure For Execution (insert/update Only)?

Feb 28, 2008

Hi,
I'm reasonably new to ASP.NET 2.0
I'm in my wizard_FinishButtonClick event, and from here, I want to take data from the form and some session variables and put it into my database via a stored procedure.  I also want the stored procedure to return an output value.  I do not need to perform a select or a delete.
For the life of me, I can't find a single example online or in my reference books that tells me how to accomplish this task using a SqlDataSource control.  I can find lots of examples on sqldatasources that have a select statements (I don't need one) and use insert and update sql statements instead of stored procedures (I use stored procedures).
I desperately need the syntax to:
a) create the SqlDataSource with the appropriate syntax for calling a stored procedure to update and/or insert (again, this design side of VS2005 won't let me configure this datasource without including a select statement...which I don't need).
b) syntax on how to create the parameters that will be sent to the stored procedure for this sqldatasource (including output parameters).
c) syntax on how to set the values for these parameters (again...coming from form controls and session variables)
d) syntax on how to execute, in the code-behind, the stored procedure via the sqldatasource.
If anybody has sample code or a link or two, I would be most appreciative.
Thank you in advance for any help!

View 5 Replies View Related

How To Execute Dts Packge By Button Control?

May 22, 2007

Hi, I have a Button control on web form, and want to execute dts package instead of procedure.
How can I do that?  I am using vb.
 
Thanks.
Michelle

View 2 Replies View Related

SqlDataSource, GridView && A Button

Jan 12, 2008

hi .. i have a SqlDataSource, GridView & a Button ..  i want to increase the condition in the "SelectCommand" below by one everytime i click the button .. i mean to be like that ID < 8 instead of ID < 7
so, the GridView will show 7 ID's instead of 6 .. and it will increase everytime i hit the button<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connectionstring %>"
SelectCommand="SELECT * FROM [table1] WHERE ID < 7">
</asp:SqlDataSource>
 

View 4 Replies View Related

Print Search Button Not Visible In Reportviewer Control In Firefox

Sep 27, 2007


Dear Friends,

I am facing the following issue in SSRS:

Problem:
When SSRS report is viewed in Reportviewer control in FIREFOX browser, then Print,Zoom and Search tool bar icons are not displayed.

The same problem is also seen, when SSRS report is viewed using URL in Firefox browser.

Description:
When SSRS report is viewed using reportviewer control in IE browser, then All tool bar icons are displayed.
Following are the Toolbar icons displayed:
1. Search.
2. Next Prev Button
3. Print
4. Zoom
5. Export

But, when the same SSRS report is viewed using Reportviewer control in Firefox browser, then following toolbar icons are not displayed:
1. Print
2. Zoom
3. Search

I would appreciate any pointers to resolve this issue.

Thanks,
S Suresh

View 1 Replies View Related

Print Search Button Not Visible In Reportviewer Control In Firefox

Sep 27, 2007


Dear Friends,

I am facing the following issue in SSRS:

Problem:
When SSRS report is viewed in Reportviewer control in FIREFOX browser, then Print,Zoom and Search tool bar icons are not displayed.

The same problem is also seen, when SSRS report is viewed using URL in Firefox browser.

Description:
When SSRS report is viewed using reportviewer control in IE browser, then All tool bar icons are displayed.
Following are the Toolbar icons displayed:
1. Search.
2. Next Prev Button
3. Print
4. Zoom
5. Export

But, when the same SSRS report is viewed using Reportviewer control in Firefox browser, then following toolbar icons are not displayed:
1. Print
2. Zoom
3. Search

I would appreciate any pointers to resolve this issue.

Thanks,
kk

View 5 Replies View Related

How To Populate Grid From SQLDataSource When Clicking On Button

Nov 20, 2007

how to populate grid from SQLDataSource  when clicking  on button

View 2 Replies View Related

Binding A Gridview To Sqldatasource On Button Click

Mar 3, 2008

 i am using 2 textbox to search name and instituition of some students. on button click  need to display the result on gridview. but i dont get any result.. pl adviceSqlDataSource1.SelectCommand = "SELECT Sname, Address, Instituition, Role, Testgroup, Email FROM std_det WHERE (Sname LIKE '%'+@Param1+'%') AND (Instituition = 'RASET') AND (Role LIKE '%'+@Param2+'%') AND (Instituition = 'RASET')";            name.ControlID = "TextBox3";            name.DefaultValue = "%";            name.Name = "Param1";            name.PropertyName = "Text";            inst.ControlID = "TextBox4";            inst.DefaultValue = "%";            inst.Name = "Param2";            inst.PropertyName = "Text";            //SqlDataSource1.Select(DataSourceSelectArguments.Empty);            SqlDataSource1.SelectParameters.Add(name);            SqlDataSource1.SelectParameters.Add(inst);            SqlDataSource1.DataBind();            //DataView dv = (DataView)this.SqlDataSource1.Select(DataSourceSelectArguments.Empty);            GridView2.DataSourceID = "SqlDataSource1";                        GridView2.DataBind();

View 2 Replies View Related

Set Sqldatasource Parameter Value At Onclick Event Of Button

May 14, 2008

i have formview and gridview in onepage, and formview bind to one sqldatasource, which have select commandtype is storedprocedure,
now stored procedure have one optional parameter and select command.
 in gridview i have one button,now i want when user click on tha button that record's value comes in formview and its mode is edit.
now for that i have to pass that stored procedures parameter value,to stored procedure now how can i add the parameter value when the onclick event of gridview button is fire.
 thanks

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

Sqldatasource Control

Oct 23, 2007

please explain selectparameters and conflict detection property within sqldatasource control
mohsen

View 1 Replies View Related

Sqldatasource Control

May 6, 2008

hi friends,
I created sqldatasource control. In select command i written the query like this  "select * form emp" and bounded in grid.How can I change the query for searching the details according the date wise when i click the search button.
 

View 14 Replies View Related

SqlDataSource Control

Jun 7, 2008

Hello experts
i have a SqlDataSource Control on my web form. Here is the source for the control
<asp:SqlDataSource ID="sqlSearchDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DbefomsConnectionString %>"
SelectCommand="SELECT [icon], [file_name], [path] FROM [tblfile] WHERE ([file_name] = @file_name)">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" DefaultValue="0" Name="file_name" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
This control displays icon, file_name, path in GridView Control
The problem is How can i store the above field values in an asp.net variable.
Thanks
Regards
Ali

View 1 Replies View Related

Using The Sqldatasource Control

Dec 7, 2005

Do you have to use the sqldatasource in conjuction with another control like gridview or dropdown list?
I'd like to check to see if a record exists in one table before inserting data into another.
 
thanks
 

View 1 Replies View Related

SqlDataSource Control

Jan 31, 2006

Hello.I'm new to ASP.NET and trying to write data to a Microsft SQL Server. I have created a SqlDataSource control, which is 'connected' to my SQL server.Now my question is how i can put data in the database throw the control, and read data from it. I've read the site, but it's still unclear for me..Greetings!

View 1 Replies View Related

SqlDataSource Control Timeout

Aug 8, 2006

How do you set a timeout for an SqlDataSource control?

View 1 Replies View Related

How To Control SqlDataSource If We Know Only DataSourceID ?

Jan 16, 2007

Anyone can help me ?

View 4 Replies View Related

SqlDataSource Control Error

Jan 19, 2007

Hello:
I am having a little issue with an error that is frustrating me. I have a SqlDataSource within an asp:label control and also have a two dropdownlists inside that asp:label control also. When I select from the first dropdownlist, it should enable the second dropdownlist with the populated data, but instead I receive.
The SqlDataSource control 'sqlGetMLSByCity' does not have a naming container.  Ensure that the control is added to the page before calling DataBind.
Any ideas why this would be? Here is the web from portion:
<asp:Label ID="recip_form_request" runat="server" Visible="false">    <ul>        <li>Step one: Select listing type.</li>        <li>Step two: Select the City that you are reciprocating to.</li>        <li>Step three: Complete the Recip Form.</li>    </ul>    <asp:DropDownList ID="recip_form_type" runat="server" AutoPostBack="true" Visible="False">        <asp:ListItem Value="0" Text="(Select Form)"></asp:ListItem>        <asp:ListItem Value="1" Text="Residential"></asp:ListItem>    </asp:DropDownList>    <br />    <asp:DropDownList ID="outside_assoc_cities" runat="server" AutoPostBack="True" Enabled="False" DataTextField="city" DataValueField="id" Visible="False"></asp:DropDownList><br />    <asp:Label ID="city_mls_desc" runat="server"></asp:Label><br />    <asp:Button ID="page1_btn" runat="server" Text="Next >>" Visible="False" />    <asp:SqlDataSource ID="sqlCities" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>" SelectCommandType="Text" SelectCommand="SELECT id, city FROM  tCityMaster"></asp:SqlDataSource>    <asp:SqlDataSource ID="sqlGetMLSByCity" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>">        <SelectParameters>            <asp:ControlParameter ControlID="outside_assoc_cities" Name="City" />        </SelectParameters>    </asp:SqlDataSource></asp:Label>
then the code behind:
Protected Sub outside_assoc_cities_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles outside_assoc_cities.SelectedIndexChanged        If outside_assoc_cities.SelectedIndex > -1 Then            Dim ItemId As Integer = Integer.Parse(outside_assoc_cities.SelectedValue)            Dim MLSID As String = Nothing
            Dim cmd As New SqlCommand            Dim con As New SqlConnection            cmd.Connection = con
            Dim sqlGetMLSByCity_sql As SqlDataSource = CType(Page.FindControl("sqlGetMLSByCity"), SqlDataSource)            'using connectionstring from SqlDataSource Control            con.ConnectionString = sqlGetMLSByCity_sql.ConnectionString            'con.ConnectionString = sqlGetMLSByCity.ConnectionString
            cmd.CommandType = CommandType.Text            cmd.CommandText = "SELECT mls_id FROM pwaordev..tCityMaster WITH(NOLOCK) WHERE ID=@ID"
            cmd.Parameters.Add("@ID", SqlDbType.Int, 4).Value = ItemId
            Try                con.Open()                MLSID = cmd.ExecuteScalar                con.Dispose()                cmd.Dispose()            Catch ex As Exception                con.Dispose()                cmd.Dispose()                Response.Write(ex.ToString())            End Try
            'Further logic to display button depending on MLS            If Not String.IsNullOrEmpty(MLSID) Then                If MLSID = "B" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Greater South Bay MLS."                    page1_btn.Visible = True                ElseIf MLSID = "A" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Big Bear BOR, MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "C" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Combined L.A./Westside MLS."                    page1_btn.Visible = True                ElseIf MLSID = "F" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Crisnet MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "Y" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is DCAoR - Yucca Valley Area, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "D" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Desert Area MLS."                    page1_btn.Visible = True                ElseIf MLSID = "L" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is i-Tech Glendale/Pasadena."                    page1_btn.Visible = True                ElseIf MLSID = "M" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is MRM - Multi-Regional MLS."                    page1_btn.Visible = True                ElseIf MLSID = "R" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is RIM - Rim of the World MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "G" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SDI - San Diego, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "S" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SOCAL MLS - Southern California MLS."                    page1_btn.Visible = True                ElseIf MLSID = "T" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Outside Area, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                End If                'test.Text = MLSID                'If test.Text = "L" Then                'mls_text.Text = "i-Tech"                'End If            End If        End If    End Sub
Any help would be great, thank you!

View 1 Replies View Related

How To Control The Loading Of SqlDataSource?

Sep 20, 2007

I have an SqlDatSource that I have fully setup at design time, but I don't want it to open and load as soon as the page loads, instead I want to open it based on a condition.
How do you do that with a DataSource?
I know that I can simply remove the Select query, and then set it at run time, but I'm looking for something better, that allows me to have the Select query set at design time, in part because I have a lot of parameters.

View 3 Replies View Related

SqlDataSource Control Synchronization

Sep 29, 2007

Hello:
I have two SqlDataSource controls on two different pages: one is updating a table and the other is reading from the same table.
Now is it possible that the reader SqlDataSource control can be refreshed immediately (to reflect updates) when the other control updates the table?

View 1 Replies View Related

UpdateCommand In Sqldatasource Control

Oct 15, 2007

Hello all,
I am trying to update the record which involed the modification of key in Datakeynames, but when i click the update button from gridview, it doesn't allow to change the value of modified column.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"                 ConnectionString="<%$ ConnectionStrings:WebsiteDataConnection %>" OldValuesParameterFormatString="old_{0}"                SelectCommand="SELECT * FROM [ServiceAgents]"                InsertCommand="INSERT INTO ServiceAgents VALUES(@Ser_STATE, @Ser_CITY, @Ser_AGENT, @Ser_PHONE, @Ser_EQUIPMENT)"                UpdateCommand="UPDATE ServiceAgents SET AGENT=@AGENT, PHONE=@PHONE WHERE (STATE=@STATE and CITY=@CITY and AGENT=@old_AGENT and EQUIPMENT=@EQUIPMENT)"                DeleteCommand="DELETE FROM ServiceAgents WHERE (STATE=@STATE and CITY=@CITY and AGENT=@AGENT and EQUIPMENT=@EQUIPMENT)" >                                <UpdateParameters>                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="PHONE" />                                         <asp:Parameter Name="old_AGENT" />                    <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </UpdateParameters>                                <InsertParameters>                    <asp:ControlParameter Name="Ser_STATE" ControlID="TextBox_state"/>                    <asp:ControlParameter Name="Ser_CITY" ControlID="TextBox_city"/>                    <asp:ControlParameter Name="Ser_AGENT" ControlID="TextBox_agent"/>                    <asp:ControlParameter Name="Ser_PHONE" ControlID="TextBox_phone"/>                    <asp:ControlParameter Name="Ser_EQUIPMENT" ControlID="TextBox_equip" />                   </InsertParameters>                                <DeleteParameters>                   <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </DeleteParameters>                            </asp:SqlDataSource>
Does anyone got any ideas about it? Where is wrong in the control?

View 3 Replies View Related

FilterExpression And The SQLDataSource Control

Feb 16, 2008

I have a SQLDatasource control on a web page. It is the datasource for a gridview control.I want the gridview to show all jones if the FirstName textbox is left blank or empty. Right now I have to put a % in the FirstName textbox to get what I want. If I make the FirstNameTextBox empty or remove the % from the FirstNameTextbox it returns all the names in the database no matter what the last name is.How do I get it to work without having to use the % in the FirstName Textbox? THANKS!FilterExpression="LastName LIKE '%{0}%' and FirstName LIKE '%{1}%'"><FilterParameters>            <asp:ControlParameter ControlID="LastNameTextBox" Name="LastName" PropertyName="Text" DefaultValue="" />            <asp:ControlParameter ControlID="FirstNameTextBox" Name="FirstName" PropertyName="Text" DefaultValue="" /></FilterParameters>
Last Name: Jones___________First Name: %_____________FILTERBUTTON
GridviewLast Name      First NameBob                JonesBill                 Jones
 

View 6 Replies View Related

SqlDataSource And Wizard Control

Apr 8, 2008

I have not found anything useful on the Wizard control.  Anything I can find gets to the last step and then just takes the info you supplied and applies them to a bunch of Label.Text's - none that do work. 
So I am building a Wizard control for an HR system that will insert the information into SQL through a SqlDataSource.  The problem is, only the controls that are present in whichever step is currently selected in VWD will appear in the Command and Parameter Editor.
I tried to work around it by selecting the first step, then applying the controls in step 1 within the Parameter Editor, but when I go back to do step 2, it erases everything I just did for step 1.
How do I implement the Wizard with a SqlDataSource?

View 8 Replies View Related

Confused Need Help With SQLDataSource Control

Jun 2, 2008

I have a gridview that is tied to a SQLDataSource control. As the gridview is filled some of the ASPX code calls some code in the code behind page. Where I am having trouble is that in one of these calls I need to some how pass the id filed ("LISTID")of the table for the SQL statement in the code behind page and I'm not sure how to do it.
The code behind function is always using the same id and I do not know how to change it. Below is all the code.
 
Here is the calling code in the ASPX page.
"DeleteBtn" Visible='<%# IsDeleteBtnVisible %>' runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#003399"> Here is the entire ASPX code.     class="header">            class="title">My Lists         "Span1">            Current List Filter:             "DropDownList2" cssclass="filterdropdown" AutoPostBack="true" runat="server">                "Active" Value="False">                "Done" Value="true">                                    --------------------------------------------------------------------------------"separator2"/>                        "list2">        "ScriptManager1"  EnablePartialRendering="true"  runat="server">          "Up2" UpdateMode="Conditional" runat="server">                                                                  "GridView1" runat="server" AutoGenerateColumns="False"                         DataKeyNames="LISTID" DataSourceID="SqlDataSource1"                        AllowPaging="True" AllowSorting="True" EnableViewState="False" GridLines="None"                         AlternatingRowStyle-BackColor="#FFFFCC" AlternatingRowStyle-Font-Size="Small"                         ForeColor="#FFFFCC" Font-Size="Small" AlternatingRowStyle-ForeColor="Black"                         Width="100%" HeaderStyle-ForeColor="White">                                                     "False">                                                            "LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update" ForeColor="#003399">                                "LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" ForeColor="#003399">                                                                                        "LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ForeColor="#003399">                                "DeleteBtn" Visible='<%# IsDeleteBtnVisible %>' runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#003399">                                                        "buttons">                            "commands">                                                                        "ITEM_DETAILS"  HeaderText="Details"  SortExpression="ITEM_DETAILS" ControlStyle-ForeColor="#003399">                            "name_edit">                            "name">                            "name">                                                                        "Pri" itemStyle-HorizontalAlign="Center" SortExpression="Priority" ControlStyle-ForeColor="#003399">                                                            "DropDownList1" Width="75" SelectedValue='<%# Bind("Priority") %>' runat="server">                                    "High" Value="3">                                    "Medium" Value="2">                                    "Low" Value="1">                                                                                                                                                        "pri" Text='<%# FormatPriority(Eval("Priority")) %>' runat="server">                                                        "priority">                            "#003399">                            "priority">                                                                        "DUEDATE" itemStyle-HorizontalAlign="Center"                              HeaderText="Due Date" DataFormatString="{0:MM/dd/yyyy}"                            SortExpression="DUEDATE" >
                            "Center">                        
                        "COMPLETEDON" itemStyle-HorizontalAlign="Center"                              HeaderText="Completed On" DataFormatString="{0:MM/dd/yyyy}"                            SortExpression="COMPLETEDON" >
                            "Center">                        
                        "Done" itemStyle-HorizontalAlign="Center" SortExpression="IsComplete">                                                            "CheckBox1" runat="server" Checked='<%# Bind("IsComplete") %>'>                                                        "iscomplete">                            "iscomplete">                                                            "Done" Text='<%# FormatDone(Eval("IsComplete")) %>' runat="server">                                                                                           
                                                                                                "Button2" runat="server" CommandName="Something" DataTextField="LISTID" DataTextFormatString="{0} active items" text='<%# Eval("LISTID") %>'>                                                                                                                                                                                                  "Empty">No lists                                                                        "White">                        "#FFFFCC" Font-Size="Small" ForeColor="Black">                                                                                                                         "Div1">               "Up3" UpdateMode="Conditional"  runat="server">                                            Add New List: "AddItem2" cssclass="newitem"                     runat="server">                "Button1" runat="server" OnClick="AddListBtn_Click" Text="Add">                                "txtdate" runat="server">                                                        "Button1" EventName="Click">                                                                        "SqlDataSource1" runat="server"         ConnectionString="&lt;%$ ConnectionStrings:FastTrackConnectionString %>"         SelectCommand="SELECT * FROM [TODO]">     Here is the code behind page code. Protected Function IsDeleteBtnVisible() As Boolean        '        Return IIf(itemCount = 0, True, False)
        'This is for my gridview        Dim strConn2 As SqlConnection = New SqlConnection        Dim cmd2 As SqlCommand = New SqlCommand        Dim rs2 As SqlDataReader        Dim test1 As String        Dim test2 As String
        strConn2.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("FastTrackConnectionString2").ToString()        strConn2.Open()
        cmd2.Connection = strConn2        cmd2.CommandText = "SELECT LISTID, (SELECT COUNT(0) AS ItemCount FROM TODO_SUB_ITEMS WHERE(LISTID = TODO.LISTID) AND (ISCOMPLETE ='False')) AS ItemCount FROM TODO WHERE (ISCOMPLETE ='False')"
        rs2 = cmd2.ExecuteReader()
        rs2.Read()
        Dim testlistid As Integer = rs2(0)        Dim intholder As Integer = rs2(1)
        strConn2.Close()        cmd2 = Nothing        strConn2 = Nothing
        Return IIf(intholder = 0, True, False)
    End Function

View 7 Replies View Related

Another SQLDataSource Control Question

Jun 4, 2008

I have a gridview that is filled from a SQLDataSource control when the page loads.
I need to do some updates and delets on this data and I wanted to know can you add more than one SQL statement to a SQLDataSource control or do I have to have a seprate control for each operation?
The SQL currently is just the standard SELECT *, I cannnot see a way to add statments.
Thanks,
Ty

View 3 Replies View Related

Question Regarding The SqlDataSource Control

Jun 11, 2008

There is something I don't understand or I am just missing something here.
Why is it that I can place an SqlDataSource1.Insert() or update, or delete, but not an SqlDataSource.Select() inside a button click event "for an example" without getting an Compilation Error?
Thanks,
xyz789

View 2 Replies View Related

SqlDataSource Control Does Not Appear In Designer

Feb 1, 2006

I have dragged 3 SqlDataSource Controls to the WebDesigner and none are appearing graphically in the Designer View, but they are in the Source View.  How can I get the control to appear in the designer.
 
Thanks,
Mark

View 5 Replies View Related

Configuring A SQLDatasource Control

Feb 26, 2006

When I configure a SQLDataSource control I want the following where clause...
WHERE     (RegionID = @RegionID AND DistrictID IS NULL AND CampusID IS NULL) OR (DistrictID = @DistrictID AND CampusID IS NULL ) OR(CampusID = @CampusID AND UserRole = 'CampusAdmin') OR (CampusID = @CampusID)but it gets reformated as....
WHERE     (RegionID = 'Region10') AND (DistrictID IS NULL) AND (CampusID IS NULL) OR                      (DistrictID = 2) AND (CampusID IS NULL) OR (CampusID = '999999103') AND (UserRole = 'CampusAdmin') OR                       (CampusID = '999999103')I don't think these are functionaly equivelant, are they?If not how do I stop the 'wizard' from reformatting the SQL where clause?Thanks

View 3 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.

View 7 Replies View Related

Sqldatasource Control Inserting Problems

Oct 6, 2006

I set up a Sqldatasource control in 2.0 and I can retrieve data through a SQL Server connection from a stored procedure.  My problem is when I set up the insert command object through the wizard for the Sqldatasource control with another stored procedure for inserting data and call the insert method of my Sqldatasource object i get nothing not even an error it just goes through the code like nothing was wrong and I don't get anything inserted.  I don't know if this could be a problem but one of the parameters in the stored procedure is declared like this: @return tinyint output. I don't know how the Sqldatasource accounts for return parameters.  Here is the code for the insert for the Sqldatasource object.<asp:SqlDataSource ID="sdsMain" runat="server" ConnectionString="<%$ ConnectionStrings:SN_CUSTOMERConnectionString %>"InsertCommand="uspSNOrder_Promo_Live" InsertCommandType="StoredProcedure" SelectCommand="uspOPFillPromo"SelectCommandType="StoredProcedure"><InsertParameters><asp:ControlParameter ControlID="ddlPromo" Name="promoid" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="1" Name="datasourceid" Type="Int32" /><asp:Parameter DefaultValue="0" Name="datasourcekey" Type="String" /><asp:Parameter DefaultValue="9" Name="salesroomid" Type="Int32" /><asp:Parameter DefaultValue="9999" Name="userid" Type="Int32" /><asp:ControlParameter ControlID="txtFName" DefaultValue="" Name="firstname" PropertyName="Text"Type="String" /><asp:ControlParameter ControlID="txtLName" Name="lastname" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtAddress" Name="address" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtCity" Name="city" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtState" Name="state" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtZip" Name="zip" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtPhone" Name="phone" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtEmail" Name="email" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="0" Direction="InputOutput" Name="return" Type="Byte" /></InsertParameters></asp:SqlDataSource>Thanks in advance

View 1 Replies View Related







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