c# syntax

Results 1 to 2 of 2

Thread: c# syntax

  1. #1
    Join Date
    Dec 1969

    Default c# syntax

    Problem: How can I access categoryid out side this foreach loop? <BR>basically I need to pass the categoryid(as it is in the Response.Write)<BR><BR>foreach(ListItem item in chk_categories.Items) <BR>{<BR>if(item.Selected) <BR>{<BR>string categoryid=item.Value +",";<BR>}<BR>} <BR>Response.Write(categoryid.Substring(0,category id.Length-1));<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: c# syntax

    Then you have to declare it outside of the foreach loop. <BR><BR>[code language="C#"]<BR>string categoryid = "";<BR><BR>foreach(ListItem item in chk_categories.Items)<BR>{<BR> if(item.Selected)<BR> {<BR> categoryid += item.Value +",";<BR> }<BR>}<BR>Response.Write(categoryid.Substring(0,ca tegoryid.Length-1));<BR>[/code]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts