awilderbeast
asked on
insert using stored procedure from code behind?
hi all,
i have a simple form that im using to insert a record, on the button "create".onclick
ive added the below
my only problem is i dont know how to pass the parameters and fields to the stored procedure?
i have a simple form that im using to insert a record, on the button "create".onclick
ive added the below
my only problem is i dont know how to pass the parameters and fields to the stored procedure?
protected void butCreatePlan_Click(object sender, EventArgs e)
{
dsCreatePlan.ConnectionString = strConnection;
dsCreatePlan.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
dsCreatePlan.InsertCommand = "sp_Plan_Insert";
//?
dsCreatePlan.Insert();
}
Here's a good link : Using parameters with SQLDatasource Control
ASKER
no there is no code in the aspx, im trying to do it all from the codebehind...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi awilderbeast,
curious why code behind?
I'm a big fan of codeless databinding, just drag a sqldatasource onto the page, right click, choose configure datasource, enter the connection defined in your web.config, choose your stored procedures from the offered lists, do the same for the edit,insert and delete tabs, test the select sproc, click ok. All your parameters will be defined appropriately in the sqldatasource parameters section. Then drag a form/gridview/datalist/wha tever on the page, right click, choose the datasource, then configure datasource again, all your formview templates will be created codelessly; take it for a spin. If all works out ok, style up the formview templates for presentation. Code behind should look like:
Alan
curious why code behind?
I'm a big fan of codeless databinding, just drag a sqldatasource onto the page, right click, choose configure datasource, enter the connection defined in your web.config, choose your stored procedures from the offered lists, do the same for the edit,insert and delete tabs, test the select sproc, click ok. All your parameters will be defined appropriately in the sqldatasource parameters section. Then drag a form/gridview/datalist/wha
Partial Class Default2
Inherits System.Web.UI.Page
End Class
Beautiful, maintainable, scalable, manageble ...Alan
It would help if you posted your aspx code.
If the parameters are declared you simply:
dsCreatePlan.InsertParamet