Saturday, 28 September 2013

Html.lablefor to display empty instead of column name in case model.Columnname value is NULL

Html.lablefor to display empty instead of column name in case
model.Columnname value is NULL

Am trying to display the value in razor view from model using the below code
@Html.LabelFor(m=>m.testId, Model.testId)
Which displays the value of testId from DB which renders as
<label for="LeadTimeText_DTD">12</label>
But incase the testID is null am getting the column name in label display
<label for="LeadTimeText_DTD">testId</label>
Where i want to display nothing like below in case if testID is null
<label for="LeadTimeText_DTD"></label>
is there any other way i do with HTML helper ? what i am doing wrong ?

No comments:

Post a Comment