Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Repeater Control Problem

Reply
Thread Tools

Repeater Control Problem

 
 
Sam Solomon
Guest
Posts: n/a
 
      09-20-2005
Dear All,

I have a Repeater Control which gets populated from the Database table.I
have a
separate column which has checkbox in it. So the last column of the repeater
control is a check box. Now I have a separate Button called delete . What I
want is that when I press the delete button I want all the rows in the
Repeater Control which have the check box clicked to be deleted from the
database.Basically I want to select all the rows and delete them by pressing
the delete button.

Below is my Code:


private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)

{

BindGrid();

}

}


void BindGrid()

{

SqlCommand cmdNorth;
SqlDataReader dtrNorth;
cmdNorth = new SqlCommand("Select EmployeeID,LastName,FirstName from
Employees",conNorth);
dtrNorth = cmdNorth.ExecuteReader();
Repeater1.DataSource=dtrNorth;
Repeater1.DataBind();
dtrNorth.Close();

}


private void Button1_Click(object sender, System.EventArgs e)
{
foreach(RepeaterItem rptRow in Repeater1.Items)

{
CheckBox ckhAuthors = (CheckBox)(rptRow.FindControl("ckhAuthors"));
if(ckhAuthors.Checked==true)
{

/****

What do I should write here???

******/
}
}

BindGrid();

}

<ItemTemplate>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,"Employe eID")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"LastNam e")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"FirstNa me")%></td>
<td><asp:CheckBox ID="ckhAuthors"
Text="Selected"=Runat="server"></asp:CheckBox></td>
</tr></ItemTemplate>

Any Help will be much appreciated.

Thanking you in Anticipation.

cheers,
Sam Solomon


 
Reply With Quote
 
 
 
 
mohammad asif
Guest
Posts: n/a
 
      09-21-2005
I don't know about the C# syntax. But this is what I do logically. What I am
assuming is that your EmployeeId is unique. Based on that, I would execute a
delete query . what you might wanna do for efficiency is create a stored
procedure for delete, and pass the employeeID of the row with a checkbox
checked.
"Sam Solomon" <Sam http://www.velocityreviews.com/forums/(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear All,
>
> I have a Repeater Control which gets populated from the Database table.I
> have a
> separate column which has checkbox in it. So the last column of the
> repeater
> control is a check box. Now I have a separate Button called delete . What
> I
> want is that when I press the delete button I want all the rows in the
> Repeater Control which have the check box clicked to be deleted from the
> database.Basically I want to select all the rows and delete them by
> pressing
> the delete button.
>
> Below is my Code:
>
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> if(!IsPostBack)
>
> {
>
> BindGrid();
>
> }
>
> }
>
>
> void BindGrid()
>
> {
>
> SqlCommand cmdNorth;
> SqlDataReader dtrNorth;
> cmdNorth = new SqlCommand("Select EmployeeID,LastName,FirstName from
> Employees",conNorth);
> dtrNorth = cmdNorth.ExecuteReader();
> Repeater1.DataSource=dtrNorth;
> Repeater1.DataBind();
> dtrNorth.Close();
>
> }
>
>
> private void Button1_Click(object sender, System.EventArgs e)
> {
> foreach(RepeaterItem rptRow in Repeater1.Items)
>
> {
> CheckBox ckhAuthors = (CheckBox)(rptRow.FindControl("ckhAuthors"));
> if(ckhAuthors.Checked==true)
> {
>
> /****
>
> What do I should write here???
>
> ******/
> }
> }
>
> BindGrid();
>
> }
>
> <ItemTemplate>
> <tr>
> <td><%#DataBinder.Eval(Container.DataItem,"Employe eID")%></td>
> <td><%#DataBinder.Eval(Container.DataItem,"LastNam e")%></td>
> <td><%#DataBinder.Eval(Container.DataItem,"FirstNa me")%></td>
> <td><asp:CheckBox ID="ckhAuthors"
> Text="Selected"=Runat="server"></asp:CheckBox></td>
> </tr></ItemTemplate>
>
> Any Help will be much appreciated.
>
> Thanking you in Anticipation.
>
> cheers,
> Sam Solomon
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeater inside a repeater problem. uncensored ASP .Net 0 10-25-2006 06:10 PM
Repeater inside a Repeater Microsoft ASP .Net Web Controls 0 08-21-2006 09:13 AM
Repeater inside a repeater....how? voidfill3d@yahoo.com ASP .Net 1 08-10-2005 01:58 PM
Repeater Using Javascript Referencing a Column in the Repeater rwoo_98@yahoo.com ASP .Net 0 02-26-2005 05:02 PM
Repeater control with nested repeater chris.reed@digus.com ASP .Net 0 02-11-2005 05:10 PM



Advertisments