How to pass list as parameter to stored procedure? [Resolved]

Posted by Vijetha under C# on 3/12/2012 | Points: 10 | Views : 3269 | Status : [Member] | Replies : 5
protected void btnOrder_Click(object sender, EventArgs e)
{
int r = grd5.SelectedIndex;
int count = grd5.Rows.Count;
List<ItemInsertItems> objItemAddtionList = new List<ItemInsertItems>();
ItemInsertItems objItemData = new ItemInsertItems();------(the class where properties for input parameters to stored procedure is defined)
for (int i = 0; i < count; i++)
{
objItemData.CUSTCODE = TxtCustCode.Text;
objItemData.QTY = ((TextBox)grd5.Rows[i].Cells[6].FindControl("txtQty")).Text.Trim();
objItemData.PRICE = ((Label)grd5.Rows[i].Cells[4].FindControl("lblRPrice")).Text.Trim();
objItemData.SKU = ((Label)grd5.Rows[i].Cells[1].FindControl("lblRsku")).Text.Trim();
objItemAddtionList.Add(objItemData);
}

ServiceAccess objserviceAccess = new ServiceAccess();
// bool result = objserviceAccess.SetItemInfo();--(i need to pass the list as parameter to this particular web method)
Response.Redirect("OrderConfirmation.aspx");
}
But not able to send the list as parameter to the above method.Wat is the other way that i can do it.




Responses

Posted by: Hmanjarawala on: 3/12/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi Vijetha,

you can't pass List<> variables to store procedure as a parameter.
do one thing, iterate loop on each member of List<> variable and pass properties as parameters to store procedures.



Mark this as answer, if it helps you...........

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Vijetha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/12/2012 [Member] Silver | Points: 25

Up
0
Down
Please refer this for an alternative way
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm

Vijetha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijetha on: 3/13/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
I have rowcommand event already where im caculating the total(price*quantity),at the end of the grid i need the grand total which has to sum up the totals so far.
How do i need to add the footer and is there need of writing rowdatabound event.??if i add the rowdatabound event the execution happens first at rowdatabound event rather at row command where the total field remains "0"(zero).
So how do i proceed?
protected void grd5_RowCommand(object sender, GridViewCommandEventArgs e)
{
int r = grd5.SelectedIndex;
int count = grd5.Rows.Count;
ItemInsertItems objItemData = new ItemInsertItems();
for (int i = 0; i < count; i++)
{
if (e.CommandName == "Calculate")
{
double price = Convert.ToDouble(((Label)grd5.Rows[i].Cells[4].FindControl("lblRPrice")).Text.Trim());
int txtQty = int.Parse(((TextBox)grd5.Rows[i].Cells[6].FindControl("txtQty")).Text.Trim());
((Label)grd5.Rows[i].Cells[6].FindControl("lbltotal")).Text = Convert.ToString(price * txtQty);

total = total + Convert.ToDecimal(((Label)grd5.Rows[i].Cells[6].FindControl("lbltotal")).Text);//(i need to reflect this total in my footer grand total label value.)

}

}

}


Vijetha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijetha on: 3/13/2012 [Member] Starter | Points: 25

Up
0
Down


}


Vijetha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Vijetha,

plz check attachment
 Download source file

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Vijetha, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response