In the controlle,r I have this 开发者_JAVA技巧code:
var result = Request.Form[0];
where result has a value of 123,test,12,45,12/23/2010
...etc..
How can I store each value in one variable?
This feels like "broken as designed," but:
string result = (string)Request.Form[0];
string []results = result.Split(',');
I am not sure what you want to do maybe try this-
string str =Request.Form[0].Select(c=>c.FormFieldName).ToString();
ideally you should get values using the id -
string valueforid=Request.Form["Id"].Tostring();
It sounds like you're asking to have each of those values stored in a variable. It's not clear, as the question is written, what your end goal is.
Consider simply accessing those values by their array position.
string[] myValues = Request.Form[0]
.ToString()
.Split(',', StringSplitOptions.RemoveEmptyEntries);
foreach (string value in myValues)
{
//do something
}
or
string customerID = myValues[0];
string customerName = myValues[1];
精彩评论