Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I 'm begginer in asp.net. I have a repeater that user can select several item for delete (by checking checkbox of any item) and click on an button for delete selected items.

in onclick event of this button, I want read id of selected item and pass them to Storeprocedure for delete from DB.
Now my ask is:
1. how to pass Id ("Feed_ID") of selected item when the check box is checked in below code?
also I want that when a item selected(user checked checkbox) background color of selected item changed. how to do this?
this is my repeater code:
ASP.NET
<ItemTemplate>
                            <div id="rptRssContent">
                                <div id="rptRssVisibleBtn" class="RepeaterDivs"  style="width:5%;">
                                        <a id="RssVisibleLink" href='Default.aspx?VisibleRssId=<%#Eval("Feed_ID") %>'>
                                        <asp:Image ID="EditLinkImg" runat="server" ImageUrl="~/Images/eye(3).png"  Width="30px" Height="30px"/>
                                        </a>
                                </div>

                                <div id="rptRssEditBtn" class="RepeaterDivs" style="width:5%;">
                                        <a id="EditRssLink" href='Default.aspx?EditRssId=<%#Eval("Feed_ID") %>'>
                                        <asp:Image ID="EditRssImg" runat="server" ImageUrl="~/image/pencil.png"  Width="30px" Height="30px"/>
                                        </a>
                                </div>
                                <div id="rptRssDeleteChkDiv"  class="RepeaterDivs" style="width:5%;">
                                        <asp:CheckBox ID="rptRssDeleteChk" runat="server" />
                                </div>

                                <div id="rptRssTitle" class="RepeaterDivs" style="width:15%;">
                                  <%#Eval("FTitle")%>
                                    
                                </div>
                                <div id="rptRssDescription" class="RepeaterDivs" style="width:45%;">
                                  <%#Eval("FDescription")%>
                                    
                                </div>
                                <div id="rptRssUrl" class="RepeaterDivs" style="width:15%;">
                                    <%#Eval("FUrl") %>
                                </div>
                                <div id="rptRssPublicationDate" class="RepeaterDivs" style="width:10%;">
                                    <%#Eval("FPublicationDate") %>
                                </div>
                                <div class="RepeaterDivs" style="width:100%;">
                                    <hr />
                                </div>
                            </div>
                        </ItemTemplate>

I thanks a lot :)
Posted
Updated 23-Dec-14 19:23pm
v3
Comments
Sinisa Hajnal 24-Dec-14 4:33am    
What have you tried? Since you have needed ID on the page, iterate through repeater items, check if it is checked and get the ID. What is the problem?

1 solution

Add Feed_ID as the value of the checkbox...
ASP.NET
<asp:checkbox id="rptRssDeleteChk" runat="server" value="<%#Eval("Feed_ID") %>" />

Pick all the checked checkboxes upon button click, and read them values...
To understand how ASP.NET templates are working, please read here: Understanding ASP.NET Templates[^]
 
Share this answer
 
v2
Comments
Bahare Aghabarari 25-Dec-14 14:13pm    
Thanks for answer. please explain this part: xmlns:asp="#unknown"
What does this mean?
Kornfeld Eliyahu Peter 25-Dec-14 14:28pm    
It means an bug with the editor here at CP :-)!
See my updated 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