I
Iain
Hi All
I am witing a web app using Delphi developer 2006 (C# app) and I have a
datagrid. Excuse the numptyness of the question. I have a datagrid with
the ability to Insert, Edit/Update and Delete records.
The following is the datagrid definition
<asp:datagrid id="Livery"
runat="server"
allowsorting="True"
EnableViewState="true"
itemstyle-verticalalign="top"
headerstyle-font-bold="true"
headerstyle-forecolor="white"
headerstyle-backcolor="black"
autogeneratecolumns="false"
font-size="8pt"
cellpadding="5"
width="92%"
onsortcommand="Livery_SortCommand"
ondeletecommand="Livery_DeleteCommand"
oneditcommand="Livery_EditCommand"
onupdatecommand="Livery_UpdateCommand"
oncancelcommand="Livery_CancelCommand">
<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0">
</EditItemStyle>
<ItemStyle verticalalign="Top">
</ItemStyle>
<HeaderStyle font-bold="True"
forecolor="White"
backcolor="Black">
</HeaderStyle>
<Columns>
<ASP:EditCommandColumn buttontype="PushButton"
updatetext="Update"
headertext="Edit"
canceltext="Cancel"
edittext="Edit">
</ASP:EditCommandColumn>
<ASP:BoundColumn datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<ASP:ButtonColumn text="Delete"
buttontype="PushButton"
headertext="Delete"
commandname="Delete">
</ASP:ButtonColumn>
</Columns>
</asp:datagrid>
The following is the Delete event which fires when I select the Delete
Button.
protected void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
..........
switch(e.Item.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
{
Button btn = (Button)e.Item.Cells[0].Controls[0];
btn.Attributes.Add("onclick",
"return confirm('are you sure you want to delete this')");
break;
}
}
..........
Delete Record If Required
..........
}
This piece of code - I grabbed this off an example on the web - fires
but I am not sure that it is what I want. Do I understand this
correctly in that it is creating a button (called btn) and adding an
onclick event to it.
What I need is for the confirm to execute and return a value so that I
can confirm the deleting of the record selected.
Can anyone point me in the right direction ?
Thanks in advance for any help offered
Iain
I am witing a web app using Delphi developer 2006 (C# app) and I have a
datagrid. Excuse the numptyness of the question. I have a datagrid with
the ability to Insert, Edit/Update and Delete records.
The following is the datagrid definition
<asp:datagrid id="Livery"
runat="server"
allowsorting="True"
EnableViewState="true"
itemstyle-verticalalign="top"
headerstyle-font-bold="true"
headerstyle-forecolor="white"
headerstyle-backcolor="black"
autogeneratecolumns="false"
font-size="8pt"
cellpadding="5"
width="92%"
onsortcommand="Livery_SortCommand"
ondeletecommand="Livery_DeleteCommand"
oneditcommand="Livery_EditCommand"
onupdatecommand="Livery_UpdateCommand"
oncancelcommand="Livery_CancelCommand">
<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0">
</EditItemStyle>
<ItemStyle verticalalign="Top">
</ItemStyle>
<HeaderStyle font-bold="True"
forecolor="White"
backcolor="Black">
</HeaderStyle>
<Columns>
<ASP:EditCommandColumn buttontype="PushButton"
updatetext="Update"
headertext="Edit"
canceltext="Cancel"
edittext="Edit">
</ASP:EditCommandColumn>
<ASP:BoundColumn datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<ASP:ButtonColumn text="Delete"
buttontype="PushButton"
headertext="Delete"
commandname="Delete">
</ASP:ButtonColumn>
</Columns>
</asp:datagrid>
The following is the Delete event which fires when I select the Delete
Button.
protected void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
..........
switch(e.Item.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
{
Button btn = (Button)e.Item.Cells[0].Controls[0];
btn.Attributes.Add("onclick",
"return confirm('are you sure you want to delete this')");
break;
}
}
..........
Delete Record If Required
..........
}
This piece of code - I grabbed this off an example on the web - fires
but I am not sure that it is what I want. Do I understand this
correctly in that it is creating a button (called btn) and adding an
onclick event to it.
What I need is for the confirm to execute and return a value so that I
can confirm the deleting of the record selected.
Can anyone point me in the right direction ?
Thanks in advance for any help offered
Iain