Rank: Member Groups: Member
Joined: 10/13/2009 Posts: 14
|
I'm using a grid containing around 10 columns, the first one is a checkbox and the column header is called "Tag PUs". A user will click 1 or more checkboxes and then hit a button called "Send Notification". It looks like it's doing a postback. That being said, whichever rows were checked are now off again. Do I have to use some sort of session variable? If so, how do I set it?
I was wanting to do a FOR loop like this (NOTE: "checker" is the variable that checks to see if the checkbox is ON or not.
for (int x = 0; x < Grid1.Items.Count; x++) { sEmailBody = ""; sEmailSubj = ""; bool checker = Convert.ToBoolean(Grid1.Items[x].Cells[0].Value); if (checker == true) { sPickupNum = Grid1.Items[x].Cells["PickUpNo"].Value.ToString().Trim(); sCustOrdNum = Grid1.Items[x].Cells["CustOrdNum"].Value.ToString().Trim(); sPONum = Grid1.Items[x].Cells["PONum"].Value.ToString().Trim(); sDateReady = Grid1.Items[x].Cells["DateReady"].Value.ToString().Substring(0, 10).Trim(); sPUTime = Grid1.Items[x].Cells["Descrip"].Value.ToString().Trim(); sPickupLocn = Grid1.Items[x].Cells["PickupLocn"].Value.ToString().Trim(); sDelAgentLocn = Grid1.Items[x].Cells["DelAgentLocn"].Value.ToString().Trim(); sTotShipUnits = Grid1.Items[x].Cells["TotShipUnits"].Value.ToString().Trim(); sTotWeight = Grid1.Items[x].Cells["TotWeight"].Value.ToString().Trim(); sTotCubes = Grid1.Items[x].Cells["TotCubes"].Value.ToString().Trim(); sCreatedOn = Grid1.Items[x].Cells["CreatedOn"].Value.ToString().Substring(0, 10).Trim(); sComments = Grid1.Items[x].Cells["Comments"].Value.ToString().Trim();
sEmailSubj = "Please schedule pickup# " + sPickupNum + " at " + sPickupLocn;
sEmailBody += currentuser + " has asked for you to please schedule the following pickup: " + "\n\n"; sEmailBody += "Pickup#: " + sPickupNum + "\r\n"; sEmailBody += "Pickup At: " + sPickupLocn + "\r\n"; sEmailBody += "Delivering To: " + sDelAgentLocn + "\r\n"; sEmailBody += "V.T.#: " + sCustOrdNum + "\r\n"; sEmailBody += "P.O.#: " + sPONum + "\r\n"; sEmailBody += "Date Ready: " + sDateReady + "\r\n"; sEmailBody += "Est. Pickup Time: " + sPUTime + "\r\n"; sEmailBody += "Total Shipping Units: " + sTotShipUnits + " / Total Weight: " + sTotWeight + " / Total Cubes: " + sTotCubes + "\r\n"; sEmailBody += "Assigned By: " + currentuser + "\r\n"; emaildt = new DateTime(); sPUStat = "ASSIGNED"; nvcEmail.CreateEmail(sSmtpServer, sMailFrom, sMailTo, sEmailSubj, sEmailBody);
ExelWebMisc.InsertPickupWIP(sConnectionString, sPickupNum, sPUStat, emailalias, sMailTo, emaildt, sComments, currentuser); }
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Your code looks fine to us. The Grid supposes to keep the data (thus retain check status) after post backs unless you explicitly wiped the data out (for example, re-bind the Grid to your data source). You can try to test this in an empty page with no additional code at all and see if it works for you. If that still does not work, please post the full test page and we will try to run it here and see if it demonstrates the same problem.
Thanks!
|
Rank: Member Groups: Member
Joined: 10/13/2009 Posts: 14
|
That fixed it. I was reloading the grid regardless of whether it was or wasn't a postback. I moved that line of code so that it only does it IF (!Page.IsPostBack) and it worked. Thanks for your help!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are welcome. Glad that it worked for you!
|