title: how to bind imageurl of datalist to the image control which is out side of datalist on insert command
body: <p>I have a image coltrol out side of datalist, I want to assign the image url to this image control on insert command.</p>
  
  <p>Data List:</p>
  
  <pre><code>&lt;asp:DataList ID="DataList1" runat="server" RepeatDirection="Vertical" onitemcommand="DataList1_ItemCommand" onitemdatabound="DataList1_ItemDataBound" CaptionAlign="Right" CellSpacing="6"&gt;
  &lt;ItemTemplate&gt;
  &lt;asp:ImageButton ID="Image" runat="server" ImageUrl='&lt;%#"~/Controls/ShowImage.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %&gt;'
   OnCommand="Insert_Command" CommandArgument='&lt;%# Eval("Id").ToString() +";"+Eval("FilePath")%&gt;' /&gt;
   &lt;asp:Label ID="lblimagenumber" runat ="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "FileName") %&gt;' &gt;&lt;/asp:Label&gt;
  &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>image control out side the datalist:</p>
  
  <pre><code>&lt;div id="loadarea" class="imageViewArea"&gt;
          &lt;asp:Image ID="imgthumb" runat="server" /&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>insert command:</p>
  
  <pre><code>protected void Insert_Command(object sender, CommandEventArgs e)
      {
          string[] str = e.CommandArgument.ToString().Split(';');
          hImgInsId.Value = str[0];
          ImgName = str[1];
  
          //Image imgThumb = (Image)this.FindControl("imgthumb");
          //imgThumb.ImageUrl=
          //how to assign datalist image url to image contol here...?
          // this is datalist imagebtn imageurl ImageUrl='&lt;%#"~/Controls/ShowImage.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %&gt;'
      }
  
     public void BindImages()
      {
          List&lt;int&gt; ImgIds = new List&lt;int&gt;();
          List&lt;string&gt; imgFileName = new List&lt;string&gt;();
          txbCaption.Text = "";
          if (ImgUpLoad.ImgFleIds != null)
              ImgIds = ImgUpLoad.ImgFleIds;
          if (ViewState["imgIds"] != null)
          {
              List&lt;int&gt; oldids = (List&lt;int&gt;)ViewState["imgIds"];
              ImgIds.AddRange(oldids);
              ImgIds.Sort();
          }
          path = objGetBaseCase.GetImages(ImgIds);
          for (int i = 0; i &lt; path.Count; i++)
          {
              ArrayList alst = path[i];
              if (i == 0)
                  hImgInsId.Value = alst[0].ToString();
  
              tb.Rows.Add(Convert.ToInt32(alst[0]), "Figure " + (i + 1).ToString(), alst[2].ToString());
              imgIds.Add(Convert.ToInt32(alst[0]));
              imgFileName.Add(alst[2].ToString());
          }
          ViewState["imgIds"] = imgIds;
          ViewState["imgFileName"] = imgFileName;
          DataList1.DataSource = tb;
          DataBind();
          ImgIds.Clear();
          if (DataList1.Items.Count == 1)
          {
  
              Label lblimgname = (Label)DataList1.Items[0].FindControl("lblimagenumber");
              lblimgname.Style.Add(HtmlTextWriterStyle.Color, "Red");
              lblimgname.Font.Bold = true;
              if (imgIdCapHtbl != null &amp;&amp; imgIdCapHtbl.ContainsKey(imgIds[0]))
                  txbCaption.Text = imgIdCapHtbl[imgIds[0]].ToString();
          }
  
      }
  </code></pre>