about viewstate
Ok I have got ViewState["AddressID"]
a开发者_Python百科nd this ViewState["AddressID1"]
both storing AddressIDs..Now if I want something like :-
if its ViewState["AddressID"]
{
call method 1
}
if its ViewState["AddressID1"]
{
call method 2
}
now how do I check if its ViewState["AddressID"]
or ViewState["AddressID1"]
?
string addressId = ViewState["AddressID"] as string;
string addressId1 = ViewState["AddressID1"] as string;
if (!string.IsNullOrEmpty(addressId))
{
method1(addressId);
}
else if (!string.IsNullOrEmpty(addressId1))
{
method2(addressId1);
}
If a ViewState
key doesn't have a value it is null, so:
if (ViewState["AddressID"] != null)
Method1(ViewState["AddressID"] as string);
else
Method2(ViewState["AddressID1"] as string);
精彩评论