locked
ASP.NET: How to distribute objects (xap files) dynamicaly in runtime? RRS feed

  • Question

  • Hello,

    In my application I download some xml data file from some information center, add to this xml file (in aspx.cs) the column with images and all together I pass to the GridView in aspx file.

    The same I want to do with xap (Silverlight) files - I need to add them to the GridView according to the data context, but unfortunatelly there is a problem - object doesn't have an object.Attributes like image does.

    Here is my code for adding images (gvCurrency is a GridView):

       for (int i = 0; i < currency.Count; i++)

       {

         Image image = new Image();

         image.Attributes.Add("src", "Images/Currency/" + xdoc.GetElementsByTagName("CURRENCYCODE")[i].InnerText + ".gif");

         image.Attributes.Add("height", "15px");

         image.Attributes.Add("width", "21px");

         gvCurrency.Rows[i].Cells[0].Controls.Add(image);

       }

    Is it possible to solve the problem?

    Thanks.

    Monday, August 1, 2011 2:08 PM

Answers

  • Hello Sergey,

    I solved the problem in a most
    simple way - I directly built the table by Response.Write (see code below).

    In your link I don't get how to assign items to rows in a right (choosed) way?

    Here is the (cutted) code:

    Response.Write(strTableHeader);
    Response.Write(strTableHeaderRow); 
    Response.Write(strTableHeaderTxt);
    …
    for (int i = 0; i <currency.Count; i++)
    {
      … 
      if(i % 2 == 0) 
        Response.Write(strTableRowEven); 
      else 
        Response.Write(strTableRowOdd); 
      Response.Write("<td>");
      Response.Write(strImg);
      Response.Write("</td>");
      … 
      Response.Write("<td>");
      if(change.Item(i).InnerText.Contains('-'))
      {
        if (i % 2 == 0)
          strXapUp1 = "ClientBin/ArrowDownEven.xap";
        else
          strXapUp1 = "ClientBin/ArrowDownOdd.xap";
     }
     else
     {
        if (i % 2 == 0)
          strXapUp1 = "ClientBin/ArrowUpEven.xap";
        else
          strXapUp1 = "ClientBin/ArrowUpOdd.xap";
      }
      Response.Write(strXapUp0 + strXapUp1+ strXapUp2);
      Response.Write("</td>");
      Response.Write("</tr>");
    }
    Response.Write("</table>");

     

    Thanks,

    LeonidZ

    http://www.lzel.net

    Wednesday, August 3, 2011 3:38 PM

All replies

  • Hi,

    Try something like this

    Monday, August 1, 2011 4:32 PM
  • Hello Sergey,

    I solved the problem in a most
    simple way - I directly built the table by Response.Write (see code below).

    In your link I don't get how to assign items to rows in a right (choosed) way?

    Here is the (cutted) code:

    Response.Write(strTableHeader);
    Response.Write(strTableHeaderRow); 
    Response.Write(strTableHeaderTxt);
    …
    for (int i = 0; i <currency.Count; i++)
    {
      … 
      if(i % 2 == 0) 
        Response.Write(strTableRowEven); 
      else 
        Response.Write(strTableRowOdd); 
      Response.Write("<td>");
      Response.Write(strImg);
      Response.Write("</td>");
      … 
      Response.Write("<td>");
      if(change.Item(i).InnerText.Contains('-'))
      {
        if (i % 2 == 0)
          strXapUp1 = "ClientBin/ArrowDownEven.xap";
        else
          strXapUp1 = "ClientBin/ArrowDownOdd.xap";
     }
     else
     {
        if (i % 2 == 0)
          strXapUp1 = "ClientBin/ArrowUpEven.xap";
        else
          strXapUp1 = "ClientBin/ArrowUpOdd.xap";
      }
      Response.Write(strXapUp0 + strXapUp1+ strXapUp2);
      Response.Write("</td>");
      Response.Write("</tr>");
    }
    Response.Write("</table>");

     

    Thanks,

    LeonidZ

    http://www.lzel.net

    Wednesday, August 3, 2011 3:38 PM