We can replace an if(){} else {} sequence, by Ternary operator like so:
txtname.Text = ue.name != string.Empty ? TextUtils.Prettyname(ue.name) : string.Empty;
instead of
if (ue.name != string.Empty)
{
txtname.Text = TextUtilss.Prettyname(ue.name);
}
else
{
txtname.Text = string.Empty;
}
<%# (Eval(Container.DataItem,"Col_3").ToString()=="")?DataBinder.Eval(Container.DataItem,"Col_2"):DataBinder.Eval(Container.DataItem,"Col_3")%>
Example:
var value = ViewState["AValue"];
MyTextbox.Text = (value != null) ? value .ToString() : String.Empty;
txtname.Text = ue.name != string.Empty ? TextUtils.Prettyname(ue.name) : string.Empty;
instead of
if (ue.name != string.Empty)
{
txtname.Text = TextUtilss.Prettyname(ue.name);
}
else
{
txtname.Text = string.Empty;
}
<%# (Eval(Container.DataItem,"Col_3").ToString()=="")?DataBinder.Eval(Container.DataItem,"Col_2"):DataBinder.Eval(Container.DataItem,"Col_3")%>
Example:
var value = ViewState["AValue"];
MyTextbox.Text = (value != null) ? value .ToString() : String.Empty;