downlist.SelectedItem.Selected=false;
if the downlist's SelectedItem
is null,开发者_Python百科after running this code,there will be a error what "Object refrence not set to an object";
how can i modify the code to this
downlist.ClearSelection();
afert modifying,can i avoid above-mentioned exception
Well, how about the following?
if (downlist.SelectedItem != null)
{
downlist.SelectedItem.Selected=false;
}
Im sure that if I fully understood your problem then there would be a more sophisticated solution, but this should do the trick (unless multiple threads access downlist.SelectedItem
, which they shouldn't in a typical ASP.Net application).
精彩评论