C
CalSun
I have a datagrid with a templatecolumn where I have the Delete linkbuttons.
As I click on the Del linkbutton, it calls the delete_func. However, I can't
get the value of the cell to use it as a key in sql_delete statement.
Here is my delete buttons
<asp:TemplateColumn HeaderText="Del/Add" ItemStyle-HorizontalAlign=Center
FooterStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:LinkButton id="btndelete" Runat=server Text="Del"
CommandName="cmdDelete" ForeColor=red>Del</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton id="btnAdd" runat="server" CommandName="cmdAddRow"
ForeColor=navy>Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateColumn>
In the delete function:
public void grid_DelAdd(Object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "cmdDelete")
{
e.Item.ItemIndex ---> this reflect the correct index on the
current datagrid
string = (string) e.Item.Cells[2].Text; ---> return an
empty string, even the field (cell) is with some data
...
}
Thanks in advance.
--Cal
As I click on the Del linkbutton, it calls the delete_func. However, I can't
get the value of the cell to use it as a key in sql_delete statement.
Here is my delete buttons
<asp:TemplateColumn HeaderText="Del/Add" ItemStyle-HorizontalAlign=Center
FooterStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:LinkButton id="btndelete" Runat=server Text="Del"
CommandName="cmdDelete" ForeColor=red>Del</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton id="btnAdd" runat="server" CommandName="cmdAddRow"
ForeColor=navy>Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateColumn>
In the delete function:
public void grid_DelAdd(Object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "cmdDelete")
{
e.Item.ItemIndex ---> this reflect the correct index on the
current datagrid
string = (string) e.Item.Cells[2].Text; ---> return an
empty string, even the field (cell) is with some data
...
}
Thanks in advance.
--Cal