c# - Switching which data field is assigned to item repeater -


i've been having hunt around , can't find out if possible. have button (inside repeater) , text of button determined couple of values being returned in dataset, this:

text='<%# databinder.eval(container.dataitem, "eventnumber") + "|" + databinder.eval(container.dataitem, "type" )%>' 

but i'd able switch field gets assigned dependant on whether eventnumber has value in it. this:

text='<%# databinder.eval(container.dataitem, "eventnumber")!=""?databinder.eval(container.dataitem, "eventnumber"):databinder.eval(container.dataitem, "productid") + "|" + databinder.eval(container.dataitem, "type" )%>' 

but can't seem work. (in instance no errors text empty)

could assist please?

thank you, craig

i recommend start using codebehind, itemdatabound best place here:

protected void repeater1_itemdatabound(object sender, repeateritemeventargs e) {     if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem)     {         datarowview row = (datarowview) e.item.dataitem;         button btn = (button) e.item.findcontrol("buttonid");         object productid = row["productid"];         object eventnumber = row["eventnumber"];         object type = row["type"];         if(dbnull.value == eventnumber || string.isnullorwhitespace(eventnumber.tostring()))         {             btn.text = string.format("{0}|{1}", productid, type);         }         else         {             btn.text = string.format("{0}", eventnumber);         }     } } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -