S
Sam Solomon
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,"EmployeeID")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"LastName")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"FirstName")%></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
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,"EmployeeID")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"LastName")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"FirstName")%></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