Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2004, 05:53 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get the checkbox id

hi
i have datalist and i use from checkbox in datalist then
when i want select checkbox item in runtime and delete it's like hotmail or yahoo mailbox but i don't khow what i do ?
because checkbox.id return same value for each row

<asp:CheckBox ID="CheckBox" runat="server" AutoPostBack="True"></asp:CheckBox></TD>
private void delete_Click(object sender, System.EventArgs e)
        {
            bool isDeleted;
            // Check each box and see if the item should be deleted.
            int I=1;
            foreach(DataListItem anItem in DataList1.Items)
            {
                I=I+1;
                string Check;
                Check=((CheckBox)anItem.FindControl("CheckBox")).I D;
                ((CheckBox)anItem.FindControl("CheckBox")).ID=Chec k+I.ToString();
                isDeleted =((CheckBox)anItem.FindControl("Check+I.ToString() ")).Checked;
                if (isDeleted)
                {

please help me ;

 
Old August 14th, 2004, 11:10 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

if I were you I would use below algorithm
Code:
private void delete_Click(object sender, System.EventArgs e)
{
   foreach(DataListItem anItem in DataList1.Items)
   {
   if (((CheckBox)anItem.FindControl("CheckBox")).Checked)
     {
  //1-I delete from datasource through an deletecommand(like "DELETE yourtable WHERE [email protected]",you should use parameters here)  the row which it's number is according to anItem.ItemIndex
     }
   }
//2-I retrieve new datasource and bind my datalist
}
HTH.

--------------------------------------------
Mehdi.:)
 
Old August 16th, 2004, 02:14 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mehdi62b
 if I were you I would use below algorithm
Code:
private void delete_Click(object sender, System.EventArgs e)
{
   foreach(DataListItem anItem in DataList1.Items)
   {
   if (((CheckBox)anItem.FindControl("CheckBox")).Checked)
     {
  //1-I delete from datasource through an deletecommand(like "DELETE yourtable WHERE [email protected]",you should use parameters here)  the row which it's number is according to anItem.ItemIndex
     }
   }
//2-I retrieve new datasource and bind my datalist
}
HTH.

--------------------------------------------
Mehdi.:)
thank's alot from your idea






Similar Threads
Thread Thread Starter Forum Replies Last Post
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
'this.ID = id;' in class construction holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 6th, 2006 10:58 AM
Duplicate ID? johno BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 10th, 2005 11:24 PM
ID crmpicco HTML Code Clinic 5 February 10th, 2005 11:50 AM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.