Solved

Looping through datagrid and prompting user with a OK/Cancel or Yes/No message box

Posted on 2007-12-03
1
165 Views
Last Modified: 2010-04-15
I'm am looping through a datagrid, and depending on some logic, I want to prompt the user within the loop if they want to continue or not.  So, I need to have a message box embedded in my loop that has an OK/Cancel or Yes/No prompt.  What do I need to do to get this working?

This would be written in c# ASP.NET

Below in my code, the part where it verified for the "W", I put code where I need this to work, it reads:

if msgbox("WARNING: Form <form #> is already attached to this risk. Would you like to attach again?) = yes then
     Session["WordingAttached"] = "false";
else
     Session["WordingAttached"] = "true";
end if

So, I need the code modified above to work....

Thanks...

foreach(DataGridItem dgAttachedItem in dgAttachedWordings.Items)

{

if (dgAttachedItem.Cells[1].Text == dgItem.Cells[1].Text)

{

 

//wording duplicate rules

if (dgAttachedItem.Cells[3].Text == "T" || dgItem.Cells[4].Text == "T")

{

MsgBox("Form " + dgAttachedItem.Cells[1].Text + " is already attached to the risk. Duplicate attachment of this form not allowed.");

Session["WordingAttached"] = "true";

}

else if (dgAttachedItem.Cells[3].Text == "A" || dgItem.Cells[4].Text == "A")

{

Session["WordingAttached"] = "false";

}

else if (dgAttachedItem.Cells[3].Text == "W" || dgItem.Cells[4].Text == "W")

{

	if msgbox("WARNING: Form <form #> is already attached to this risk. Would you like to attach again?) = yes then

	

		Session["WordingAttached"] = "false";

		

	else

	

		Session["WordingAttached"] = "true";

	end if

	

}

else

{

Session["WordingAttached"] = "true";

}

 

break;

}

else

{

Session["WordingAttached"] = "false";

}

 

}

Open in new window

0
Comment
Question by:michael1174
1 Comment
 
LVL 16

Accepted Solution

by:
TSmooth earned 500 total points
ID: 20395620
The MsgBox method can't be used with ASP.NET because ASP.NET code is executed on the server and thus it would just pop the message box with prompt up on the server which no one usually sees and it would just sit there waiting for a response.

Due to the disconnected/stateless nature of the web, you may want to re-think what you are trying to accomplish and if there's a smarter way to achieve the same result. If you wanted to continue with an approach like this, you would need to store the index of the datagrid row you are working on in your loop as a session variable and then make your looping function capable of starting at the given start index and continuing. Your prompt for the user would need to come back in the form of some html code.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using Simpleject with Class Library 11 25
C# Reverse int in fast ways 6 29
Problem to open Excel file 15 44
Round up to 100% in .NET 10 46
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now