i display tags on the page separated by commas
eg:tag1,tag2,tag3
if i have only 1 tag it should add
eg:tag1
not
eg:tag1,
if i have only 2 tag it should add
eg:tag1,tag2
not
eg:tag1,tag2,
how to do that because my functions returns with comma
while
(dtardrTagOther.Read()){
strOtherTags += dtardrTagOther.GetValue(0).ToString()+ ",";
}
Hello,Just discard the last comma from the strOtherTags after the end of while loop. like
while
(dtardrTagOther.Read()){
strOtherTags += dtardrTagOther.GetValue(0).ToString()+ ",";
}
strOtherTags = strOtherTags.Remove(strOtherTags.Length-1,1);
!!! Mark as Answer if it meets your requirement !!!
Thanks.
Try the below code
while(dtardrTagOther.Read())
{
if (strOtherTags == string.Empty)
{
strOtherTags = dtardrTagOther.GetValue(0).ToString();
}
else
strOtherTags += "," + dtardrTagOther.GetValue(0).ToString();
}
HC
after u exit while:
strOtherTags = strOtherTags.Substring(0, strOtherTags.Length - 1)
HTH
0 comments:
Post a Comment