SqlDataSource Parameter Binding (Updating)

Oct 6, 2006

Hello, I just started working with ASP.NET.
I'm trying to use the CheckBoxList Control.  As I understand it, you can bind a SqlDataSource to this control and it loads the list for you.  However tp precheck the items, you have to do this manually.  This part works fine.  Next part was to save whatever the user checks.  I wrote stored Procedure and now just trying to pass 1 parameter to the stored procedure using a second SqlDataSource.  I get the error: "A severe error occurred on the current command.  The results, if any, should be discarded."
Here is the second datasource I am using to try and save the data:
<asp:SqlDataSource ID="sds_PersonRole" runat="server" ConnectionString="<%$ ConnectionStrings:Development %>"
SelectCommand="usp_selectPersonRole"
SelectCommandType="StoredProcedure"
UpdateCommand="usp_updatePersonRole"
UpdateCommandType="StoredProcedure">
<SelectParameters>
    <asp:ControlParameter ControlID="gv_Person" Name="PERSON_ID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
    <asp:Parameter Name="strXML" Size="8000" Type="String" />
    <asp:Parameter Direction="InputOutput" Name="err_msg" Type="String" Size="150" DefaultValue="0" />
</UpdateParameters>
</asp:SqlDataSource>
I have a code behind file with the following modules:  (btnEditPerson is clicked to start the process.  the sds_PersonDetails is updated via form contolls and works fine.)  Error occurs on the bolded line (Stored procedure is just accepting the string and saving to a field.  It works fine, I tested it.  Its just erroring out before  it runs the stored procedure.
Protected Sub btnEditPerson_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEditPerson.Click
    sds_PersonDetails.Update()
    gv_Person.DataBind()

    sds_PersonRole.Update()
End Sub
 
    Protected Sub sds_PersonRole_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles sds_PersonRole.Updating
        Dim command As Data.Common.DbCommand
        command = e.Command
        'un-check all checkboxlist items (count - 1 to account for starting at 0)
        Dim listCount As Integer = cbl_Role.Items.Count() - 1
        Dim strXML As String
        strXML = "<personRole>"
        For x As Integer = 0 To listCount
            If cbl_Role.Items(x).Selected() = False Then
                strXML = strXML & "<person id='" & gv_Person.SelectedValue & "' />"
                strXML = strXML & "<role id='" & cbl_Role.Items(x).Value & "' />"
            End If
        Next
        strXML = strXML & "</personRole>"

        command.Parameters("@strXML").Value = strXML
        lbl_ErrMsg.Text = command.Parameters("@err_msg").Value.ToString()
    End Sub

View 1 Replies


ADVERTISEMENT

SqlDataSource And Parameter Binding

Jan 10, 2006

Hi, I am using a SQL DataSource with a few parameters. I need to specify the value of the parameters at run time but I need a custom way to do it as the value needs to be calculated not come from Cookie, Control, Form, Profile, QueryString or Session. Is there a way to bind your own value to these parameters. For instance if I had a variable how would I bind that to the parameter?
At the moment i am doing the following which works but I dont think it is the correct way
dsMyDataSource.SelectParameters["MyParameter"].DefaultValue = MyCalculatedValue;
In previous projects i have added a value to the Session and then bound the parameter value to the session but that doesnt seem like a good solution either.
Thanks for any help you can give.
Martin

View 9 Replies View Related

Binding A Texbox To A SQLDataSource

Feb 13, 2007

This is an easy question.  I thought I have databinded a textbox to a SQLDataSource.  But now I do not see how to do that now.  Can somebody help with this?
Thanks,

View 1 Replies View Related

Binding Textbox With SqlDataSource

Mar 9, 2007

Hi,    I wants to bind textbox with sqldatasource in c#.net so I am using following code and has following error... Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.Source Error:



Line 22: Line 23: System.Data.DataView dv = (DataView) SqlDataSource1.Select(System.Web.UI.DataSourceSelectArguments.Empty);Line 24: TextBox1.Text = dv[0]["Proid"].ToString();Line 25: Line 26: }Please, anybody knows solution tell me 

View 1 Replies View Related

Binding A SqlDataSource To A TextBox Or Label

Feb 28, 2007

I have a SQL database with 1 column in it.. it is a do not call registry for my office.  I want to make a web application so our leads can go on the web and request to be put on the do not call list.  problem is, if their number already exists, it gets a violation of primary key... Normal handling for this would be to do a select query based on user input, and if it exists in the database, tell them that, else do the insert query... Problem is, i cant seem to figure out how to bind the result of the select query to a textbox or label so i can compare the results to do that logic.  Any ideas?  This is in asp .net 2.0.  Thanks! -Dan       

View 5 Replies View Related

Binding A SqlDataSource, To A GridView At Runtime

Mar 8, 2006

Hello
I'm experiencing some problems, binding a SqlDataSource to a GridView.
The following code creates the SqlDataSource:            string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;            string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName;                        SqlDataSource ds = new SqlDataSource(strProvider, strConn);            ds.SelectCommand = "SELECT * FROM rammekategori";
Then i bind the SqlDataSource to a GridView:
         GridView1.DataSource = ds;            GridView1.DataBind();
 
ErrorMessage:
Format of the initialization string does not conform to specification starting at index 0.
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.Line 24:             GridView1.DataBind();Am i totally off target here? Can it be something about, that you have to set the datasource of the gridview, before the Page_Load event?
 
Thanks - MartinHN

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

What Is The Difference - Using Sqldatasource Control Vs Binding To Dataset Then Calling Databound()

Oct 26, 2007

Ive run into a situation where some code im using will not function the same when between these two cases.  So, this has me wondering what is going on behind the scenes.  What is the sequence of events that are occurring that would possibly be messing things up.Here is the sample codeIts a gridview that is using a sqldatasource control.  The code works fine, but if you want to bind the grid to a dataset and call databind yourself, things dont work as expected and the other features that the code performs just isnt happening, at least not for me. 

View 1 Replies View Related

Invalid Parameter Binding(s)--Please Help

Apr 6, 2006

I am real new to SQL Server. We are using SQL Server 2000.

My objective is to get a list of all store procedures for specific database. To accomplish this, I programmatically create a connection to the 'master' database where the sp resides, create a callablestatment for 'sp_stored_procedures' ({call sp_stored_procedures(?,?,?)}). I am passing in null, null, and the database name. When I execute the query, I get the below error:


Code:


java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)



When I made the connection to the master database, I used one of the existing users from the master database.

I looked at the store procedure and verified the sp has 3 input parameter. The first two can be null.

I am not sure why I can not run this sp. I am wondering if we have the database setup properly. Any help or suggestions would be well worth it at this point.


Thanks in advance for reading my post.

Russ

View 2 Replies View Related

Error - Invalid Parameter Binding

Nov 11, 2014

While trying to execute the below query I get an error "Invalid Paramter Binding.

SELECT RELEASE_CYCLES.RCYC_NAME+' : '+ CYCL_FOLD.CF_ITEM_NAME /*Test Set Folder (CYCLE).Name*/ as "Cycle Name : Test Component",
SUM(case when t3.status='Passed' then 1 else 0 end) "Passed",
SUM(case when t3.status='Failed' then 1 else 0 end) "Failed",
SUM(case when t3.status='Not Completed' then 1 else 0 end) "Not Completed",
SUM(case when t3.status='No Run' then 1 else 0 end) "No Run",
SUM(case when t3.status in ('Passed','Failed','Not Completed','No Run') then 1 else 0 end) "Total",

[code]....

View 5 Replies View Related

Binding Report/Field 'language' Setting To Query/Parameter Result.

Oct 24, 2007

Hello,

I have a report which displays a customers invoice, in both the companys local currency, and the customers local currency.

The report language is "English (United Kingdom)"
The fields showing customers currency language setting is set to something else, i.e. "France (French)" to display the Euro currency.

The application handles 34 currencies, the query returns the language string, ("France (French)"), to allow the report to bind its language setting to the querys output.

However, it doesn't work, a normal textbox will display the correct country name string, but Reporting Services cannot bind the language setting to a query result. So I also tried setting it as a report parameter, but no joy either (all currencys revert to USD).

I'm using =First(Fields!curFormat.Value, "myDataSet") to bind the 'language' setting, the result of this expression returns "France (French)", which is a valid option for this language setting, as it's in the drop down list.

Rather than create 34 seperate reports for each currency, are there any suggestions on how to bind a fields language setting to a query result?

View 3 Replies View Related

Updating A SqlDataSource

Dec 12, 2006

I am looking for a way to update a sqldatasource what I have is a ASP Wizard applicationstep oneis a dataview with the select ability it displays an ID and Namein step two what i want it to do is take the ID from step ones select and put that into the where clause so I have select * from table where id = step1selectedID

Code:

View 1 Replies View Related

Updating Using SQLDataSource

Apr 27, 2006

When I bind a GridView to a SQLDataSource where are the update parameter values set.  What event will allow me to see the paramter values.  I am trying to understand a little better how things work under the covers.
 
Jay

View 2 Replies View Related

What Is The Best Parameter To Use For A Sqldatasource When The Parameter Is The Sqlmembership Username?

Mar 15, 2008

I know i can accomplish this by setting a session variable on page load on the server side (Session["UserName"]= User.Identity.Name) and then use a session parameter, but I was wondering how to do it without using session variables, i was hoping the following code would work, but it doesn't. Thanks for any ideas.





" Name="UserName" Type="String" />

View 3 Replies View Related

Updating Data With SqlDataSource Object

Mar 6, 2007

I am updating data with sqlDatasource but it is inserting NULL, tell what I am missing <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"
DefaultMode="Insert" Width="100%">
<InsertItemTemplate>
<table width="100%">
<tr>
<td style="width: 100px">
Name</td>
<td style="width: 100px">
<asp:TextBox ID="txtCategory" runat="server" Text='<%# Eval("CategoryName") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
Parent</td>
<td style="width: 100px">
<asp:DropDownList ID="ddlParent" runat="server" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" Width="100%">
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="Insert"/></td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CommerceTemplate %>"
SelectCommand="SELECT [CategoryID], [CategoryName], [CategoryMID] FROM [CMRC_Categories]"
DeleteCommand="DELETE FROM [CMRC_Categories] WHERE [CategoryID] = @CategoryID"
InsertCommand="INSERT INTO [CMRC_Categories] ([CategoryName], [CategoryMID]) VALUES (@CategoryName, @CategoryMID)"
UpdateCommand="UPDATE [CMRC_Categories] SET [CategoryName] = @CategoryName, [CategoryMID] = @CategoryMID WHERE [CategoryID] = @CategoryID">
<DeleteParameters>
<asp:Parameter Name="CategoryID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CategoryName" Type="String" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="CategoryMID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:FormParameter Name="CategoryName" Type="String" FormField="txtCategory" />
<asp:FormParameter Name="CategoryMID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource> Please suggest  cheers
  

View 4 Replies View Related

Error - Updating Tables Row Using SqlDataSource

May 29, 2007

I have such a problem:i try to update a row in my table using:    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();    }And i receive error on  usersSqlDataSource.Update():You have specified that your update command compares all values on SqlDataSource 'usersSqlDataSource', but the dictionary passed in for oldValues is emptyWhat have i done wrong? Parameter are not set? 

View 3 Replies View Related

Need Help With Sqldatasource And Updating A Field In Sql 2005

Nov 19, 2007

I am experiencing some wacky errors here. While trying to update a field that does not allow nulls and the default value is set to '', I keep receiving an exception error that:
 Cannot insert the value NULL into column 'image_name', table 'DB_123871.dbo.tWebBlogs'; column does not allow nulls. UPDATE fails. The statement has been terminated.
 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="SqlGetBlogs" DataKeyNames="article_id" AutoGenerateColumns="False" CssClass="GridView" CellPadding="4" HorizontalAlign="Center" Width="875px">
<Columns>
<asp:CommandField CancelImageUrl="~/images/Cancel.gif" EditImageUrl="~/images/Edit.gif"
UpdateImageUrl="~/images/Update.gif" ButtonType="Image" HeaderText="Edit" ShowEditButton="True">
</asp:CommandField>
<asp:BoundField DataField="article_id" HeaderText="ID" ReadOnly="True" />
<asp:TemplateField HeaderText="Artilce Header">
<EditItemTemplate>
<asp:TextBox ID="ArticleHeaderTxt" runat="server" Text='<%# Bind("article_header") %>' Width="250"></asp:TextBox>
<asp:RequiredFieldValidator ID="ArticleHeaderTxtReq" runat="server" ControlToValidate="ArticleHeaderTxt" Display="Dynamic" EnableClientScript="true" ErrorMessage="Article Header Required" SetFocusOnError="true"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="ArticleHeaderLbl" runat="server" Text='<%# Eval("article_header") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Article Description">
<EditItemTemplate>
<asp:TextBox ID="ArticleDescriptionTxt" runat="server" Text='<%# Bind("article_description") %>' Width="325" Rows="8" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="ArticleDescTxtReq" runat="server" ControlToValidate="ArticleDescriptionTxt" Display="Dynamic" EnableClientScript="true" ErrorMessage="Article Description Required" SetFocusOnError="true"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="ArticleDescriptionLbl" runat="server" Text='<%# Eval("article_description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Link Short Text">
<EditItemTemplate>
<asp:TextBox ID="ArticleLinkTxt" runat="server" Text='<%# Bind("short_link_text") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="ArticleLinkTxtReq" runat="server" ControlToValidate="ArticleLinkTxt" Display="Dynamic" EnableClientScript="true" ErrorMessage="Article Link Text Required" SetFocusOnError="true"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="ArticleLinkLbl" runat="server" Text='<%# Eval("short_link_text") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Article Link">
<EditItemTemplate>
<asp:TextBox ID="ArticleLink" runat="server" Text='<%# Bind("article_link") %>' Width="250"></asp:TextBox>
<asp:RequiredFieldValidator ID="ArticleLinkReq" runat="server" ControlToValidate="ArticleLink" Display="Dynamic" EnableClientScript="true" ErrorMessage="Article Link URL Required" SetFocusOnError="true"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="ArticleLinkLnk" runat="server" CssClass="LinkNormal" NavigateUrl='<%# Eval("article_link") %>'
Target="_blank" Text="View Link"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image Name">
<EditItemTemplate>
<asp:TextBox ID="Image1Txt" runat="server" Text='<%# Bind("image_name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1Img" runat="server" AlternateText='<%# Eval("image_name") %>' ImageUrl='<%# Eval("image_name", "~/Blogs/Images/Thumbs/{0}") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Entered">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("article_date_entered", "{0:d}") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("article_date_entered", "{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active?">
<EditItemTemplate>
<asp:CheckBox ID="ActiveChk" runat="server" Checked='<%# Bind("active") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="ActiveChk" runat="server" Checked='<%# Eval("active") %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<asp:ImageButton ID="DeleteBtn" runat="server" AlternateText="Delete Record" CommandName="Delete"
ImageUrl="~/images/Delete.gif" OnClientClick="return confirm('Are you sure you want to delete this blog?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle HorizontalAlign="Left"></RowStyle>
<EditRowStyle Font-Bold="False"></EditRowStyle>
<HeaderStyle CssClass="GridViewHeader" HorizontalAlign="Left"></HeaderStyle>
<AlternatingRowStyle CssClass="GridViewAltRow"></AlternatingRowStyle>
</asp:GridView>
</td>
</tr>
<tr>
<td>
<div style="text-align: center;"><asp:Label ID="recordset_lbl" runat="server" CssClass="HelpTextNormal"></asp:Label></div>
</td>
</tr>
</table>
</div>

<asp:SqlDataSource ID="SqlGetBlogs" runat="server" ConnectionString="<%$ connectionStrings:dbconn1 %>"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT article_id, article_header, article_description, image_name, short_link_text, article_link, article_date_entered, active FROM tWebBlogs ORDER BY article_date_entered DESC"
SelectCommandType="Text"
UpdateCommand="UPDATE tWebBlogs SET article_header=@article_header, article_description=@article_description, image_name=@image_name, short_link_text=@short_link_text, article_link=@article_link, active=@active WHERE article_id=@article_id"
UpdateCommandType="Text"
DeleteCommandType="Text"
DeleteCommand="DELETE tWebBlogs WHERE article_id=@article_id">
<DeleteParameters>
<asp:Parameter Name="article_id" />
</DeleteParameters>
</asp:SqlDataSource> 
 Please help! I am stumped!

View 1 Replies View Related

SqlDataSource Not Updating On Editing GridView

Mar 4, 2007

Hi, I'm new in ASP 2.0. I need to incorporate edit and delete capability in GridView. Using the wizard, i've generated this code. When I delete a row, it gets deleted but update does not work. I've tried several ways. I got no error or exception. But row is not updated. I've checked database, and I think the update query is not executing at all. Please let me know, what I'm doing wrong? Here is the source code for reference. I'm using Visual Studio 2005 with SQL server 2005 Express Edition. Regards

==========================================================
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="QuoteItemID" DataSourceID="SqlDataSource1"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" CausesValidation="False" /> <asp:BoundField DataField="QuoteItemID" HeaderText="QuoteItemID" InsertVisible="False" ReadOnly="True" SortExpression="QuoteItemID" /> <asp:BoundField DataField="QuoteID" HeaderText="QuoteID" SortExpression="QuoteID" /> <asp:BoundField DataField="ChargeCodeID" HeaderText="ChargeCodeID" SortExpression="ChargeCodeID" /> <asp:BoundField DataField="RateItemAmount" HeaderText="RateItemAmount" SortExpression="RateItemAmount" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ratesdb %>" DeleteCommand="DELETE FROM [Quote_item] WHERE [QuoteItemID] = @QuoteItemID" InsertCommand="INSERT INTO [Quote_item] ([QuoteID], [ChargeCodeID], [RateItemAmount]) VALUES (@QuoteID, @ChargeCodeID, @RateItemAmount)" SelectCommand="SELECT * FROM [Quote_item]" UpdateCommand="UPDATE [Quote_item] SET [QuoteID] = @QuoteID, [ChargeCodeID] = @ChargeCodeID, [RateItemAmount] = @RateItemAmount WHERE [QuoteItemID] = @QuoteItemID" ConflictDetection="CompareAllValues"> <DeleteParameters> <asp:Parameter Name="QuoteItemID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="QuoteID" Type="Int32" /> <asp:Parameter Name="ChargeCodeID" Type="Int32" /> <asp:Parameter Name="RateItemAmount" Type="Decimal" /> <asp:Parameter Name="QuoteItemID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="QuoteID" Type="Int32" /> <asp:Parameter Name="ChargeCodeID" Type="Int32" /> <asp:Parameter Name="RateItemAmount" Type="Decimal" /> </InsertParameters> </asp:SqlDataSource>

View 6 Replies View Related

Problem Updating Data While Using Datasets And Sqldatasource

Apr 3, 2008

 




hello.i'm having the following problem.in one page i have a dataset created at runtime along side with sqldataadapter and an sqlconnection.i'm using a dataset here since i'm working with heirarchical tables.when i click on child table [in a spcific column] it opens up a new aspx page with an editing form [formview in edit mode]when
i press the update button it claims to update the data, but when i
close the form and reopen it from the same column it opens the form
again, but with the old data, and the new data doesn't get updated
until i close the openinig aspx page [the one with the table]
refreshing it doesn't work, nor does creating a postback.anyone has any ideas ?

View 2 Replies View Related

SqlDataSource Parameter

Jan 22, 2008

This is probably a simple question, but I have a form with two content windows.  In content1 using an sqldatsource1 I select a single record and display it using a FormView.
 What I need to do is using one field  from sqldatsource1 ("CategoryName", which is not displayed in formview1), in content window 2; I need to display all records with the same CategoryName. 
So the simple English version is:
Using CategoryName from SqlDataSource1 (in content window 1), select all records in SqlDatasource2 where CategoryName is = CategoryName (in content window 2). 
I am using vb code behind. 
Thanks
 

View 1 Replies View Related

Using LIKE And A Parameter In SqlDataSource

Mar 2, 2008

I have a SqlDataSource, a GridView and a TextBox (whose ID is searchTB) on my page. I can use the SqlDataSource like this:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="Data Source=TORNADO;Initial Catalog=AdventureWorks;Integrated Security=True"
        ProviderName="System.Data.SqlClient"
        SelectCommand="select * from production.product where name = @nameparam">
        <SelectParameters>
            <asp:ControlParameter ControlID="searchTB" Name="nameparam"
                PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource> 
However, I want the search to be made using the LIKE operator, ie, select * from production.product where name LIKE %THE_TEXT_FROM_TEXTBOX%.
How can I do this? Thanks

View 5 Replies View Related

Need To Set &<asp:Parameter&> On SqlDataSource

Mar 31, 2008

Hi there,
I'm still new, so please be patient with me... 
I am using C# ASP.NET 2.0.  I have a web page that uses a Calendar control to display links for events from my database.  The links use the __doPostBack to pass the EventID back to the same page.  I was getting the EventID as a string okay and then passing it into a TextBox control.  I then had an SqlDataSource control that set to display the Event in a DetailsView.  The SqlDataSource uses a control to get the EventID - I used the TextBox control.  It is all working fine, but...
What I want to do is instead of using a TextBox control - pass the string in to a public property in the class in my code-behind.  I want to use an <asp:Parameter> on my SqlDataSource control to set the control to get the EventID from my public property.  How do I do this?
Thanks in advance.
 

View 3 Replies View Related

Add Parameter To SqlDataSource

Jun 3, 2008

I have a gridview which is displaying a bunch of data.  However, I'd only like to display data based on the query string.  Here's my code:  <asp:GridView ID="gv" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CssClass="GridControl" DataKeyNames="ID">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" Visible="false" SortExpression="ID" />
<asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="Details.aspx?id={0}" Text="Details" />
<asp:BoundField DataField="Name" HeaderText="Attendee" SortExpression="Name" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand="sprocCUSTOM_GetDetail" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>and my stored procedure:    SELECT     ID, Name, Email    FROM        Events    WHERE     (ID = @eventID) So as you can see, I need to get the value from the query string to add to my stored procedure.  I know this can be done in the code-behind, but isn't there a way to add <SelectParameter> to the SqlDataSource?  I just can't get the query string in there.  

View 12 Replies View Related

SqlDataSource: Getting Parameter Value From ViewState

Aug 25, 2006

Hello all, This may be a simple question, but it is causing me some grief at the moment.I put a SqlDataSource control on my form, and pointed it to the stored procedures I had written to insert/update/delete rows in my database.The DataSource control notices that I am using parameters in my queries, and asks me to select where the parameters will be assigned from (Control, Form, Session, etc.)I am keeping the primary key value (in this case an ID number for a real estate listing) persisted in ViewState.Is there any way to access ViewState from the SqlDataSource control, or do I need to find another way to do this? Thanks,Adam 

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

Pass A Parameter To A SqlDataSource

Feb 28, 2007

I'm trying to pass my SqlDataSource a parameter that is defined in the code-behind file for the same page.  I've tried the method below but it does not work.  Is there a better way?SubmitForm.ascx page: <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ connection string...... %>"    SelectCommand="sp_CourseMaterialShipment_GetCourses" SelectCommandType="StoredProcedure">    <SelectParameters>        <asp:Parameter DefaultValue="<% ProgramID %>" Name="programID" Type="Int32" />    </SelectParameters></asp:SqlDataSource> SubmitForm.ascx.vb page:Private ProgramID as string = "25"Public ReadOnly Property ProgramID() As String        Get                        Return _ProgramID        End GetEnd Property  ThanksJason    

View 2 Replies View Related

SqlDataSource Parameter Direction

May 4, 2007

Hi,
 
In the SqlDataSource control if I go to the SelectQuery property and I set one parameter with the “direction� property to “Output� the result doesn’t display in the control, why?
 
Points:
The procedure witch is in the selectquery property the parameter in it is set to output two.

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

Parameter Name Questions In SqlDataSource????

Jul 2, 2007

I have a table with with some column name includes a space. for example [Product ID] [Product Name] Instead of Product_ID, Product_Name. when I try to create a gridview and enable delete, insert. It just won't work. 
I've been trying for several hours without success. When I click on delete. the page postback without any error, but the record doesn't get deleted or updated.
<asp:SqlDataSource id="sourceProducts" runat="server" SelectCommand="SELECT [Product ID], [Product Name] FROM Products" ConnectionString="<%$ ConnectionStrings:mydb %>"DeleteCommand="Delete from Products where [Product ID]=@ProductIDUpdateCommand="UPDATE Products SET [Product Name]=@ProductName WHERE [Product ID]=@ProductID" >    <UpdateParameters>        <asp:Parameter Name="ProductName" />        <asp:Parameter Name="ProductID" />    </UpdateParameters>    <DeleteParameters>        <asp:Parameter Name="ProductID" Type="Int32"/>    </DeleteParameters></asp:SqlDataSource><asp:GridView ID="GridView2" runat="server" DataSourceID="sourceProducts"  AutoGenerateColumns="False" DataKeyNames="Product ID" >               <Columns>      <asp:BoundField DataField="Product ID" HeaderText="ID" ReadOnly="True" />      <asp:BoundField DataField="Product Name" HeaderText="Product Name"/>      <asp:CommandField ShowEditButton="True" ShowDeleteButton="True"></asp:GridView> 
Another testing I did was to use another table with no space in the Column name, Product_ID, Product_Name. and I can't name my parameter as PID, PNAME. I have to name it as @Product_ID, @Product_Name in order for Delete, update to work. My understanding is if I declare the parameter explicitly(<asp:Parameter Name="PID" />, I can use any name I want. Did I must missed something?
 I'm new to ASP.NET, could someone help me?
 Thanks.

View 5 Replies View Related

SqlDataSource + Parameter + SELECT IN

Jul 20, 2007

I'm sure that is really simple, but how do I pass a parameter with multiple value to a SQLdatasource?
ex: SELECT field1 from tblTableA where idTableA IN ( @Param1)
 Let's say I want to pass 1,2,3,4  as Param1   (SELECT field1 from tblTableA where idTableA IN ( 1,2,3,4))
How I am supposed tu use the .SelectParameters.Add()  to pass a list of integers instead of  a single value??
Thanks in advance.

View 2 Replies View Related

SqlDataSource WHERE IN Select Parameter

Dec 5, 2007

Is it possible to use a WHERE-IN statement with a SqlDataSource control. For instance:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT [Id], [Name], [Phone] FROM [Table1] WHERE ([Id] IN @Id)">
<SelectParameters>
<asp:Parameter DefaultValue="( 1, 3, 5, 7, 11 )" Name="Id" Type="Int32" />
</SelectParameters></asp:SqlDataSource>
I'm hoping the gridview would then display a table with rows for records 1,3,5,7,11. Thanks for any help...

View 2 Replies View Related

How To Make New Parameter In Sqldatasource?

Jan 31, 2008

Hi there,I'm new to db stuffs and I'm using sqldatasource to pull my data from the server. Here's the codes.<asp:SqlDataSource ID="testSqlDataSource" runat="server"             ConnectionString="<%$ ConnectionStrings:p01impConnectionString %>"            SelectCommand="SELECT [a], [b], [c], [d], [e] FROM [MYDB] WHERE (([a] = @a) AND ([b= @b))"             CancelSelectOnNullParameter="False">            <SelectParameters>                <asp:ControlParameter ControlID="TextBox1" Name="a" PropertyName="Text" Type="String" />                <asp:ControlParameter ControlID="TextBox2" Name="b" PropertyName="Text" Type="String" />            </SelectParameters></asp:SqlDataSource>  notice that I haven't used [c], [d], [e] and I want to declare a parameter, something like: Total = c + (d*e)can anyone show me the syntax to do this UNDER sqldatasource? I then will have to put that Total in a gridview (i can solve this part)Thanks 

View 1 Replies View Related

SQLDataSource Expects Parameter

Dec 14, 2005

Problem: The system throws the following error"Procedure or Function 'sp_TestRequestFormMaster_StatusChange' expects parameter '@Status', which was not supplied."I'm using VS 2005 Final.Recreate the problem:I've created a simple stored procedure with two parameters on SQL 2005 on Win 2003 Server. @ID INT, & @Stutus INTOn a SQLDataSource Control for the Delete query, using the build button to open the Command and Parameter Editor, I click the Refresh Paramater.I set ID Parameter Source: Control, ControlID: GridView1I set Status Parameter Source: None, DefaultValue: 1001.Partial Source View:
<DeleteParameters><asp:ControlParameter ControlID="GridView1" Name="ID" propertyName="SelectedValue" Type="Int32" DefaultValue="" /> <asp:Parameter DefaultValue="1001" Name="Status" Type="Int32" /><asp:Parameter DefaultValue="" Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" /></DeleteParameters>I run the code, click the delete in the GridView and the error appears.  How can I pass a status value without relating it to a source.

View 1 Replies View Related







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