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
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
- How to get thumbnail from vimeo video URL in Python?
- Remove all special characters, punctuation except spaces from string - Python
- OSError: cannot write mode RGBA as JPEG- Python
- expected str, bytes or os.PathLike object, not JpegImageFile - Python
Related Article