Datagrid - Event Will Not Fire

I

Iain

Hi All


I have a simple page (.net 1.1 using c#) with a datagrid where I have
a column with a list of products and a column with a delete button.
See snippets of code below.

If I change the button type of the ButtonColumn to a LinkButton the
event fires.
If I change the button type of the ButtonColumn to a PushButton the
event does not fire.

The user wants a push button and I also think it is more appropriate.

Can any tell me why this occurs and how I can get the PushButton to
fire the event

Best regards and thanks in advance for any assistance offered

Iain


<asp:datagrid id="DGProductList" runat="server"
ondeletecommand="DGProductList_DeleteCommand"
horizontalalign="Center" font-bold="True" forecolor="Blue"
allowsorting="True"
itemstyle-verticalalign="top" headerstyle-font-bold="true"
headerstyle-forecolor="white"
headerstyle-backcolor="black" autogeneratecolumns="False" font-
size="9pt" cellpadding="1"
bordercolor="#C0FFFF" borderstyle="Solid" borderwidth="1px"
height="188px" pagesize="20">
<edititemstyle borderstyle="Dashed" bordercolor="#0000C0"
backcolor="#FFFFC0"></edititemstyle>
<itemstyle verticalalign="Top"></itemstyle>
<headerstyle font-bold="True" horizontalalign="Center"
borderwidth="2px" forecolor="White"
borderstyle="Double" bordercolor="red"
backcolor="Black"></headerstyle>
<columns>
<asp:boundcolumn datafield="PRODUCT" headertext="Product Name">
<headerstyle width="175px"></headerstyle>
<itemstyle horizontalalign="Left"></itemstyle>
</asp:boundcolumn>
<ASP:ButtonColumn text="Delete Product"
buttontype="PushButton"
headertext="Delete"
commandname="Delete">
<HeaderStyle width="20px"></HeaderStyle>
</ASP:ButtonColumn>
</columns>
</asp:datagrid>



protected void DGProductList_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
OleDbConnection con = new OleDbConnection("provider=IBMDA400;Data
Source=XXX.XXX.XXX.XXX;User Id=xxxxxxxx;password=xxxxxxxx");
OleDbCommand cmd = new OleDbCommand();

string LProduct = e.Item.Cells[0].Text;
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
string LSqlString = "Delete From CAPACITY.PRODUCTS Where PRODUCT =
'" + LProduct + "'";
cmd.CommandText = LSqlString;
OleDbDataReader dsBookings = cmd.ExecuteReader();
con.Close();

con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
LSqlString = "Select * From CAPACITY.PRODUCTS ORDER BY PRODUCT";
cmd.CommandText = LSqlString;
OleDbDataReader dsProducts = cmd.ExecuteReader();
DGProductList.DataSource = dsProducts;
DGProductList.DataBind();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,913
Messages
2,570,027
Members
46,420
Latest member
IsobelScha

Latest Threads

Top