| | |
How to create Check Box Controls list in Repeater/Datalist/Listview ??
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Solved Threads: 0
Hi,
I want to create a web application that have messaging feature,
thus the message inbox will be similar to typical email inbox where you can tick the checkboxes to select which email to be deleted or moved. Just like the below picture :
http://img209.imageshack.us/img209/7720/chkboxrj0.jpg
How do i create the checkbox inside the repeater/datalist/listview ??
and How to delete only the checked row ??
and lastly, I would like to add the master checkbox where when it is checked, it will check and select all the rows in that page.
Thanks for all suggestion and inputs !!
I want to create a web application that have messaging feature,
thus the message inbox will be similar to typical email inbox where you can tick the checkboxes to select which email to be deleted or moved. Just like the below picture :
http://img209.imageshack.us/img209/7720/chkboxrj0.jpg
How do i create the checkbox inside the repeater/datalist/listview ??
and How to delete only the checked row ??
and lastly, I would like to add the master checkbox where when it is checked, it will check and select all the rows in that page.
Thanks for all suggestion and inputs !!
Last edited by -mk-; Dec 15th, 2008 at 4:52 am.
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
Create a templatefield, insert the checkbox and afterwards, check with FindControl() wether the checkbox has been checked. The mastercheckbox needs to be inserted in the headerrow of the control. Also there can be checked with FindControl(). If it's checked, reload the page. Be aware that the controls need to have AutoPostback() setted to true.
If you dont want it with autopostback you need to implement some literals and javascript which is harder to fix.....
If you dont want it with autopostback you need to implement some literals and javascript which is harder to fix.....
Here is the code sample with a GridView named "gv_Lookup"
//Place this on the aspx markup page for the GridView control to show the delete checkboxes on each row and the delete button in the footer.
// Set the OnRowDeleting property of the GridView
OnRowDeleting="gv_Lookup_RowDeleting"
// This method will be called on the click of the delete button. Defined later in the code sample
// Add this to generate the verification message
//Place this on the aspx markup page for the GridView control to show the delete checkboxes on each row and the delete button in the footer.
ASP.NET Syntax (Toggle Plain Text)
<asp:TemplateField HeaderText="Delete" ShowHeader="False" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:CheckBox ID="chkDeleteRows" runat="server"/> </ItemTemplate> <FooterTemplate> <asp:LinkButton ID="lbDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton> </FooterTemplate> </asp:TemplateField>
// Set the OnRowDeleting property of the GridView
OnRowDeleting="gv_Lookup_RowDeleting"
// This method will be called on the click of the delete button. Defined later in the code sample
// Add this to generate the verification message
ASP.NET Syntax (Toggle Plain Text)
protected void gv_Lookup_RowDataBound(object sender, GridViewRowEventArgs e) { LinkButton lbDelete = (LinkButton)e.Row.FindControl("lbDelete"); if (lbDelete != null) { lbDelete.Attributes.Add("onClick", "return confirm('Are you sure, you want to delete this Lookup Value? ');"); } }
ASP.NET Syntax (Toggle Plain Text)
protected void gv_Lookup_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Looping through all the rows in the GridView foreach (GridViewRow row in gv_Lookup.Rows) { CheckBox checkbox = (CheckBox)row.FindControl("chkDeleteRows"); //Check if the checkbox is checked. if (checkbox.Checked) { // Pass the Row ID as parameter to your custom Delete Function DeleteLookupValues(Convert.ToInt32(gv_Lookup.DataKeys[row.RowIndex].Values[0])); } } LoadGrid(); // Refreshes the Grid with updated rows. }
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Solved Threads: 0
hi,
i have tried the codes, and i got this error which i cant solve it.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Any ideas ??
Thanks alot !!
i have tried the codes, and i got this error which i cant solve it.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Any ideas ??
Thanks alot !!
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: checkbox query
- Next Thread: Update record Problem.
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





