Here from the following, I am getting a var type variable in my code:
var FormID = from n in dtEnDate.AsEnumerable()
where n.Field<int>("Tax_Setup_UID") ==
Convert.ToInt32(item.GetDataKeyValue("Tax_Setup_UID"))
select n.Field<string>("FormID");
Here it is giving me the formid. Now I want to convert this var type variable to an int for next use and if I try without conversion it is giving me an error. But I can't do it.
You're returning select n.Field<string>("FormID"), so the actual type of var FormID will be IEnumerable<string>.
If you know the query will return one result, you can do something like:
int formID = int.Parse(FormID.First());
If FormID is an int in your database, change n.Field<string> to n.Field<int> and you can omit the int.Parse().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With