In this article I will explain how to convert string to integer an example. This is needed when I want to delete the number of user susing userId. I got collection of string result from List<string>iList. I need to convert string to integer below example describes about it.
[HttpPost]
public ActionResult DeleteUserLogin(List<string>iList)
{
string message = "";
UserLogin UserLogin = new UserLogin();
if (iList == null)
{
message = "No Record(s) selected.";
goto out1;
}
int i = 0;
foreach (string row_loopVariable in iList)
{
int UserLoginId = Convert.ToInt16(row_loopVariable);
i = i + 1;
if (UserLoginId > 0)
{
UserLogin.DeleteUserLogin((string)HttpContext.Session["DBConnector"], UserLoginId);
message = "Record(s) Deletedsucessfully.";
}
}
out1:
if (Request.IsAjaxRequest())
{
return Json(message, JsonRequestBehavior.AllowGet);
}
else
{
return RedirectToAction("ListUserLogin", "UserLogin", new { area = "Admin" });
}
}
Post your comments / questions
Recent Article
- Fix-Gradient effect turning to gray in after effects
- How to blur an image in python?
- ModuleNotFoundError: No module named 'whois' in Python GoviralHost Without Terminal
- How to Convert Image to Pencil Sketch in Python?
- AttributeError: module 'urllib' has no attribute 'request' - Python
- How to Extract audio from video files using python?
- PermissionError: [Errno 13] Permission denied: 'shampoo_sales.csv' - Python
- [WinError 145] The directory is not empty: 'FolderPath' - Python
Related Article