M
mamun
Hi All,
I have the following situation and am looking for answer in C#.
I have a datagrid and putting checkbox next to each record. In the
header I have a Delete button.
I want users to checkchekboxes and click the Delete button. That will
show a confirmation dialog message with the items they choose to
delete.
I have spent hours in the groups to find the similar one but without
any luck.
Here is the snippet of my code in page.aspx. The name (or id) of the
datagrid is BoreHolesResult. I will be updating based on the selected
checkbox and this checkbox should relate to the field Bore_Id.
<asp:TemplateColumn HeaderText="Type" >
<ItemTemplate>
<asp:TextBox ID="txtType" Runat="server" text='<
%#DataBinder.Eval(Container.DataItem, "BORE_TYPE") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Button ID="btnDeleteBoreId" Runat="server" Text="Delete"
Onclick="DeleteBoreID"></asp:Button>
</HeaderTemplate>
<ItemTemplate>
<center>
<asp:CheckBox ID='chkDelete' Runat="server">
</asp:CheckBox>
</center>
</ItemTemplate>
</asp:TemplateColumn>
In the code file (page.aspx.cs),
I have the following:
public void DeleteBoreID(object sender, System.EventArgs e)
{
string BoreID;
foreach (DataGridItem GridItem in BoreHolesResult.Items)
{
CheckBox myCheckbox =
(CheckBox)GridItem.Cells[8].Controls[1];
if (myCheckbox.Checked == true)
{
BoreID = GridItem.Cells[0].Text;
//here I want to show the confirm message with the
selected Bore Ids
// Cells[8] where the checkboxes are located in the datagrid 9th
item
//after confirm I will perform the delete records here.
}
}
}
I will highly appreciate your help. Thanks a million in advance.
best regards,
mamun
I have the following situation and am looking for answer in C#.
I have a datagrid and putting checkbox next to each record. In the
header I have a Delete button.
I want users to checkchekboxes and click the Delete button. That will
show a confirmation dialog message with the items they choose to
delete.
I have spent hours in the groups to find the similar one but without
any luck.
Here is the snippet of my code in page.aspx. The name (or id) of the
datagrid is BoreHolesResult. I will be updating based on the selected
checkbox and this checkbox should relate to the field Bore_Id.
<asp:TemplateColumn HeaderText="Type" >
<ItemTemplate>
<asp:TextBox ID="txtType" Runat="server" text='<
%#DataBinder.Eval(Container.DataItem, "BORE_TYPE") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Button ID="btnDeleteBoreId" Runat="server" Text="Delete"
Onclick="DeleteBoreID"></asp:Button>
</HeaderTemplate>
<ItemTemplate>
<center>
<asp:CheckBox ID='chkDelete' Runat="server">
</asp:CheckBox>
</center>
</ItemTemplate>
</asp:TemplateColumn>
In the code file (page.aspx.cs),
I have the following:
public void DeleteBoreID(object sender, System.EventArgs e)
{
string BoreID;
foreach (DataGridItem GridItem in BoreHolesResult.Items)
{
CheckBox myCheckbox =
(CheckBox)GridItem.Cells[8].Controls[1];
if (myCheckbox.Checked == true)
{
BoreID = GridItem.Cells[0].Text;
//here I want to show the confirm message with the
selected Bore Ids
// Cells[8] where the checkboxes are located in the datagrid 9th
item
//after confirm I will perform the delete records here.
}
}
}
I will highly appreciate your help. Thanks a million in advance.
best regards,
mamun