That's right. Unless you use BoundColumn, you should use e.Item.FindControl
to locate requied control.
"CalSun" <> wrote in message
news:...
> Thanks Wang. I figured out my problem. I used controlfinder and casted the
> control accordingly.
>
> --cal
>
>
> "Elton Wang" <> wrote in message
> news:%...
> > Hi Cal,
> >
> > Could you show your whole datagrid html code?
> >
> > Elton Wang
> >
> > "CalSun" <> wrote in message
> > news:%23%...
> >> 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
> >>
> >>
> >
> >
>
>
|