Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one main repeater and inside that i have one datalist which contains ImageButton ,on clicking on that button that image should get open in modelpopup with respective id.

What I have tried:

---aspx----
<asp:DataList ID="dlimgrep" Visible="false" runat="server" OnItemCommand="dlimgrep_ItemCommand" OnSelectedIndexChanged="dlimgrep_SelectedIndexChanged"  RepeatDirection="Horizontal" RepeatColumns="2" RepeatLayout="Table">
                                                      <ItemTemplate>
                                                          <asp:Label ID="lbltlphotoid" runat="server" Visible="false" Text='<%#Eval("timelinephoto_id") %>'></asp:Label>
                                                          <asp:ImageButton runat="server"   Style="margin: 0px 5px 5px 0px;" Width="150px" Height="150px" CommandName="imgshowfull" class="img-responsive" ID="imgbtn" alt="user" CommandArgument='<%#Eval("timelinephoto_id") %>' ImageUrl='<%# "~/ImagePage.aspx?tlpostphtoid=" + System.Convert.ToString(Eval("timelinephoto_id")) %>' />

                                                      </ItemTemplate>
                                                  </asp:DataList>
                                                    <cc1:ModalPopupExtender ID="ModalPopupExtender3" runat="server"  TargetControlID="dlimgrep" PopupControlID="Panelshow"
                                                                  BackgroundCssClass="modalBackground" DropShadow="true">
                                                              </cc1:ModalPopupExtender>

                                                              <asp:Panel ID="Panelshow" class="post-container" runat="server" CssClass="modalPopup" align="center" Style="display: none">
                                                                   <asp:Image runat="server" Style="margin: 0px 5px 5px 0px;" Width="450px" Height="500px" ImageAlign="Left" ID="imgfull" />
                                                                  <asp:Label ID="Label1" Text="Help Us Understand What's Happening" runat="server"></asp:Label><br>
                                                                  
                                                                      <asp:Label ID="Label5" Text="What's going on?" runat="server"></asp:Label>
                                                                  <br />

                                                                  <asp:TextBox ID="TextBox2" Visible="false" runat="server" TextMode="MultiLine"></asp:TextBox>

                                                                  <br />
                                                                  <div class="fileupload fileupload-new" data-provides="fileupload" style="margin-bottom: 10px;">

                                                                      <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatLayout="Table" CssClass="radio_gender" RepeatDirection="Vertical">
                                                                          <asp:ListItem Selected="True" Text="It's annoying or not interesting"  Value="0"></asp:ListItem>
                                                                          <asp:ListItem Text="I think it shouldn't be on BanjaraSocial" Value="1"></asp:ListItem>
                                                                          <asp:ListItem Text="It's spam" Value="2"></asp:ListItem>
                                                                      </asp:RadioButtonList>

                                                                  </div>
                                                                  <asp:Button ID="Button1" OnClick="btnContinue_Click" runat="server" Text="Continue" /> 
                                                                  <asp:Button ID="Button3" runat="server" Text="Close" />
                                                              </asp:Panel>


and
---cs---
protected void dlimgrep_ItemCommand(object source, DataListCommandEventArgs e)
 {
     SqlConnection conn = new SqlConnection(c.connStr);
     conn.Open();
     if (e.CommandName == "imgshowfull")
     {
         //Panel pan = e.Item.FindControl("Panelfull") as Panel;
         //pan.Visible = true;
         Image img = e.Item.FindControl("imgfull") as Image;

         int tlid = Convert.ToInt32(e.CommandArgument);
         SqlCommand cmdimgfull = new SqlCommand("select timeline_photos from  tbl_timelinephotos where timelinephoto_id = '" + tlid + "'", conn);
         SqlDataReader DRimg = cmdimgfull.ExecuteReader();
         if (DRimg.Read())
         {
             byte[] bytes = (byte[])(DRimg["timeline_photos"]);
             base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
             img.ImageUrl = "data:image/png;base64," + base64String;
         }
         DRimg.Close();
     }
 }
Posted
Updated 21-Mar-17 2:31am

1 solution

protected void dlimgrep_ItemCommand(object source, DataListCommandEventArgs e)
    {
        SqlConnection conn = new SqlConnection(c.connStr);
        conn.Open();
        if (e.CommandName == "imgshowfull")
        {
            ModalPopupExtender3.show()
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            //Panel pan = e.Item.FindControl("Panelfull") as Panel;
            //pan.Visible = true;
            Image img = e.Item.FindControl("imgfull") as Image;

            int tlid = Convert.ToInt32(e.CommandArgument);
            SqlCommand cmdimgfull = new SqlCommand(                                                  tbl_timelinephotos where timelinephoto_id = '" + tlid + "'", conn);
            SqlDataReader DRimg = cmdimgfull.ExecuteReader();
            if (DRimg.Read())
            {
                byte[] bytes = (byte[])(DRimg["timeline_photos"]);
                base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                img.ImageUrl = "data:image/png;base64," + base64String;
            }
            DRimg.Close();
        }
    }
 
Share this answer
 
v2
Comments
Member 11936990 22-Mar-17 1:57am    
thanks for solution.. i have already tried that 1. but the problem is when i click on image button inside datalist.. it automatically opens model popup first beacuse of targetcontrolid, and then jump to item command.. so problem is not getting solved.
kp564 22-Mar-17 4:33am    
Then you have to remove target control I'd and then u can use this code
Member 11936990 22-Mar-17 2:18am    
thanku so much it works..i tried again.
kp564 22-Mar-17 6:58am    
so,please approve this as answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900