this is xml let say:
<.Sections>
<.SECTION ID ="4" NAME="GetStudents" CONTROL-TYPE="Button" LINK="WebForm2.aspx">
</SECTION>
<.SECTION ID="5" NAME="SelectStudent" CONTROL-TYPE="Drowpdown" METHOD ="selectList_MethodName">
</SECTION>
Observe this xml, I am generating the UI controls base on “CONTROL-TYPE” Attributes. but there are different attributes are there in both sections elements. as LINK and METHOD . I want to query like this , if section’s CONTROL-TYPE==”Button” then get value of LINK attribute Else If CONTROL-TYPE==”Drowpdown” then get value of METHOD attribute Else If.
I am trying to write code in c# +ASP.net. how to achieve this? is there way get such data ?
NOTE: please don’t go on dot inside tag as <.SECTION>. it is for this forum page understanding.
Well, the simplest way is either an explicit if/else:
… or use the conditional operator if you’re happy with a simple default value for other control types:
EDIT: Within a query expression, there are two reasonable ways to do this. First, you could use the conditional operator and a
letclause to fetch the control type just once:Alternatively – and preferrably, IMO – put this logic into a method, and then call the method from the select clause: