Maybe change Page_Load into Pre_Render .... though I wouldn't if you can keep it all in Page_Load
there's loads of thing sit could be. Try setting it in ViewState and even holding it as a session var - but it can get tricky.
If you bind all of your data in a function then call that function again within the edit and update commands.
public void List_Edit(Object sender, DataListCommandEventArgs e)
{
list.EditItemIndex = (int)e.Item.ItemIndex;
//BindPagedData();
string itemID = list.DataKeys[list.EditItemIndex].ToString();
double price;
int qty;
string itemName;
string sItemDescn;
int discount;
string disctype;
string img;
bool inStock;
// get details about item
Item item = new Item();
item.GetDetails(itemID, out price, out qty, out itemName, out sItemDescn,
out discount, out disctype, out img);
//inStock = qty > 0 ? true : false;
//Change this as I shall be adding up the items purchased, starting at zero.
inStock = qty > -1 ? true : false;
//Response.Write("itemID : " + itemID + " price : " + price + " itemName : " + itemName + " itemDescn : " + sItemDescn + " img : " + img);
Session["currentSubItem_R"] = "..... " + sItemDescn + " is in <b>edit</b> mode.";
ViewState["currentSubItem_L"] = Session["currentSubItem_L"];
ViewState["currentSubItem_R"] = Session["currentSubItem_R"];
currentPage = (int)ViewState["CurrentPage"];
currentItem = (string)ViewState["CurrentItem"];
currentSubItem_L = (string)ViewState["currentSubItem_L"];
currentSubItem_R = (string)ViewState["currentSubItem_R"];
BindPagedData(); ....................................................................this is my main function that binds all the data ... it is also called from page Load
}
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
currentPage = 1;
BindPagedData();
}
}
when you response.Write(Addrow) what does it print out ?
You just need to get the whole pages structure regards load order and postbacks and events in the correct order.
Binding in Pre_Render may do it - but if you get into that habit you end up loosing a bit of leaway when it comes to importing and nesting controls in a page.