sql datasource UpdateParameters code behind

 Hi all,
i have detailsview bind to sqldatasource (directily) with select and updatecommand. Now i have 3 buttons on my page - resolved, pending, cancel

resolved - set status = "success" and comment = "somthing"
pending - set status = "inprogress" and comment = "somthing"
cancel - shoud close the asppage

how can i set in code behind this updateparameters.
DetailsView is bind directly to sqldatasource - in witch event shoud i paste the statement i dont`t know if this is right

 'SqlDataSource1.UpdateParameters.Clear()
...
        'SqlDataSource1.UpdateParameters.Add("Status", "SUCCESS").ToString()
        'SqlDataSource1.Update()

0
orimaspnet
8/11/2008 8:36:07 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
2171 Views

Similar Articles

[PageSpeed] 19

Do something like this:

ASPX 

<asp:sqldatasource id="SqlDataSource1" runat="server">
	<updateparameters>
		<asp:parameter name="Status" type="String" />
		<asp:parameter name="Comment" type="String" />
	</updateparameters>
</asp:sqldatasource>

CODE-BEHIND 

protected void btnResolved_Click(object sender, EventArgs e)
{
	SqlDataSource1.UpdateParameters["Status"].DefaultValue = "success";
	SqlDataSource1.UpdateParameters["Comment"].DefaultValue = "something";
	SqlDataSource1.Update();
}

protected void btnPending_Click(object sender, EventArgs e)
{
	SqlDataSource1.UpdateParameters["Status"].DefaultValue = "inprogress";
	SqlDataSource1.UpdateParameters["Comment"].DefaultValue = "something";
	SqlDataSource1.Update();
}

protected void btnCancel_Click(object sender, EventArgs e)
{
	Response.Redirect("~/Default.aspx");
}

Thanks, Ed

Microsoft MVP - ASP/ASP.NET

0
ecbruck
8/11/2008 10:54:35 AM

 Thanks it works.

0
orimaspnet
8/11/2008 2:01:18 PM
Reply:

Similar Artilces:

code for Custom paging without using sqldatasource control and sql datasource control for gridview...........
 code for Custom paging without using sqldatasource control and sql datasource control for gridview...........i need code for how to show all pagenumbers in gridview with custom paging in gridview..............It is very urgent................................. T.Ashok Kumar  suppose that we have a table like thisCountryId  identity intCountryTitle    nvarchar(50)you can use this sql command for paging the dataUSE [CyberOffice]GO/****** Object:  StoredProcedure [dbo].[CountryGetListPaged]    Script Date: 09/17/2008 14:01:06 ******/SET A...

SQL Datasource with code behind:
Hi all, I am trying to use a query into the code behind like that: "SELECT SELECT * FROM [ListePage] order by @id desc" the problem is that the errors says that its a non declared for the @id ------------------------------------------------- System.Data.SqlClient.SqlException: Must declare the variable '@id'. ------------------------------------------------- If I try to do this: SqlDataSource1.SelectParameters.Add(new Parameter("@id", TypeCode.String)); SqlDataSource1.SelectCommand = "SELECT * FROM [ListePage] order by @id desc"; In this ...

Setting width for .net controls in code(.aspx) page using function call in code behind..
Hi,  Currently I am trying to set the width of the asp.net Table as follows. <asp:Table width="<%=GetWidth()%>" >   and code behind protected Unit GetWidth() { return Unit.Percentage(50); }     It's not working. I know that it works if I set the width complete on some page event(like page_load) of code behind....   Is there a way to maintain the same syntax like calling code behind function in design page...i.e. calling function of .aspx.cs in .aspx page and assign the width as shown above.   Thanks and regards, Giridhar...

Moving items from the page code behind to the user control code behind.
I am trying to setup a page with a user control specified as a header. Things work fine until the user control has to access dynamic content that is in the code behind of the main page. When I try to move these commands to the code behind for the user control I get errors saying items have not been declared. What is the best way to do this, I'm mainly trying to create some headers and footers for my asp.net project. if it belongs for the header move it to the headers code behind. It is probably saying items have not been declared because you moved the methods, but not the properties to...

Code behind vrs. non code behind in VS.NET 2003
Does anyone know what the advantages and disadvantages are for using code behind vrs. non code behind in Visual Studio.Net 2003? One important difference is that you are able to separate the design of a web site from the code. This makes for ease of maintainablity and much more structured applications. If you ever worked with classic ASP the code-behind is a great invention. sivilianMy Weblogs...

Dynamic SQL in code behind, access to control parameters?
If I declare control paramters, will I be able to access these in  my code behind for a Dynamic SQL statement>?  Example:  Im building the select statement using a checkboxlist, and wish to be able to filter these results based on 3 dropdownlist.selectedvalues.  So i'll declare the control parameters in the front end, but will I be able to call those in the code behind... Induction_type and Engine_cams being the control parameters. example, I'll append my select statement (strSQL) to the following "Where Induction_Type =" + "@ Induc...

Setting focus on control in the code-behind VB.NET
Hello, Can anyone tell me if you see anything wrong with this code? I'm trying to set focus on txt_job textbox when a button is clicked. 1 Private Sub SetFocusScript(ByVal strTextBox As String) 2 3 Dim sb As New System.Text.StringBuilder() 4 5 sb.Append("<script language='javascript'>") 6 7 sb.Append("document.frmView." & strTextBox & ".focus();") 8 9 sb.Append("</script>") 10 11 ' register the script 12 13 ...

vb.net data controls not found in code behind?
I am trying to follow along some of the very basic tutorials by scott gu but using vb.net.  When I try and databind from my code behind I get an intellisense error that the control cannot be found?  Doesn't matter if it is a listview a repeater or whatever. Here is my code behind:1 Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 2 Repeater1.datasource = ViewData("Categories") 3 Repeater1.databind() 4 End SubHere is my front end aspx: 1 <%@ Page Language="vb" AutoEve...

Accessing Form Controls via code behind (VB.NET)
Hi,I hope someone can help provide some light on this problem I'm having. I have searched the forums and found another post on ASP.NET that references how to access controls on a form using for example:Dim lstResourceServers As WebControl = frmASP.FindControl("lstResourceServers")This will indeed give me access to the listbox control on the form but I can't access the properties and methods specific to the listbox control class such as Items, SelectedIndex, etc. which to me is rather pointless.If I place a listbox or any other component on my asp.net page I can directly acc...

what about the code-behind (code behind)
One MAJOR difference between AJAX.NET and Atlas.NET seems to be that AJAX.NET is able to expose methods in your codebehind to the client. Why doesn't Atlas do this? Or am I mistaken? With AJAX.NET it's just a simple line or two:  Ajax.Utility.RegisterTypeForAjax(GetType(myClass)) <Ajax.AjaxMethod()>Public Function myFunction PLEASE tell me Atlas has something comparable to this. I don't have the time to rewrite all my code-behind methods in javascript or atlas script. All you need to do in Atlas to expose a method on your page (or its code behind class) is to put a [WebMet...

how to add a query to sql datasource using a value from code behind?
 I have a value in my web form which is received from previous page and i have a sqldatasource in which i have written the query through the wizard.In this query i want to use where clause which tallies the cavlue from code behind :the code in code behind is:value1 = Request("abc")SqlDataSource1.SelectParameters("fid").DefaultValue = value1and in source:  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CoursePortalConnectionString %>"       &nb...

Code Behind or not Code Behind
Ok i am confuse now.... A lot of books are showing pages without code behind (the code is integrated in the .aspx) Is it better to use the code behind or not. Is there any difference between using VB.NET or C#.NET except for the code synthax. Thank you and come again. A lot of samples show inline code just for simplicity.. i personally use code-behind because I like to seperate my code from presentation. As for VB.NET or C#, its your preference.. there is no difference really when its all said and done. From a purely mathematical sense, having everything in a single file would s...

how come vs.net doesnt import my controls when i open the code behind?
hi all, when i write the markup for some webcontrols i'm going to use in a webform, how come vs.net doesn't automatically list these elements in the code behind, when i open it up? i don't think i should have to write the declarations myself! is there a way to configure this? VS will sync the declarations if you switch to design view after adding them in HTML view.Tim McBrideThis posting is provided "AS IS" with no warranties, and confers no rights. Is there any better answer?? This same exact problem has been driving me absolutely nuts. I am still very new to .NET. I swear that...

Set Datasource to Drop Down Control in FormView InsertTemplate Field through Code Behind
Hey , How do I set Datasource to Drop Down Control in FormView InsertTemplate/EditItemTemplate Field through Code Behind. I need this as we use general connection objects and general data retrival methods in a common Data Class. Please help? Thanks, Shyam Hi, raghavashyam: You just need to bind the datasource to the FormView(Containers) and the syntax as following in the templateFiled will bind the particlar filed to your controls.  <asp:TemplateField HeaderText="Name" >               &nb...

Web resources about - sql datasource UpdateParameters code behind - asp.net.presentation-controls

torch/nn · GitHub
Contribute to nn development by creating an account on GitHub.

Resources last updated: 1/20/2016 11:34:38 PM