In this article, I will show to convert from string to int by parsing. Here I want to increment id field in xml for new entries. In XML, data fields are in a string so that I needed to convert it to int.
Example:
DataSet ds = XmlGridView.DataSource as DataSet;
DataRow dr = (DataRow)ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1];
XmlElement ID = MyXmlDocument.CreateElement("ID");
int x = Int32.Parse(dr["ID"].ToString()); // parse string to integer c#
x++; // incrementing value
ID.InnerText = x.ToString();//assigning incremented valuee to the xml field
Output:
Post your comments / questions
Recent Article
- How to enable Search Feature in Django admin?
- How to check PAN-Aadhaar is Linked or NOT?
- How to customize pagination for django admin?
- How to fix HAXM is not installed |in Android Studio
- How to fix CMOS Checksum Error in Computer or Laptop | SOLVED
- Reactivating windows after a Hardware change on PC or Laptop
- FIXED: Windows reported that the hardware of your device has changed. Error code :0xc004F211
- "redirect" is not defined pylance("reportUndefinedVariable)
Related Article