About DataGrid Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    #1

    About DataGrid Question

    Hi there,

    I use datagrid to display my web page data and the first and the second
    column's visible property is false.
    How should I do if I want to get the first and second column's data ?
    I use the following method, but failed...

    I.
    CType(e.Item.Ce lls(0).Controls (0), TextBox).Text

    II.
    e.Item.Cells(0) .Text

    --
    PP


  • Ignacio Machin \( .NET/ C#  MVP \)

    #2
    Re: About DataGrid Question

    Hi Paul,

    Tis is a code I', using, I have the first column invisible as it contain
    the IDof the strong typed collection's item I'm binding to.
    This comes from a event handler ( Edit )

    protected void ActionEditComma nd(object sender, DataGridCommand EventArgs e)

    {

    int ID = Convert.ToInt32 (((Label)e.Item .FindControl("A ctionID")).Text )

    }

    I used a Label in the column to keep the ID value:
    <asp:templateco lumn Visible="False" >
    <itemtemplate >
    <asp:Label CssClass="text" Visible="False" id="ActionID"
    Runat="server" Text='<%# ((CtpAction)Con tainer.DataItem ).ID.ToString() %>'>
    </asp:Label>
    </itemtemplate>
    </asp:templatecol umn>


    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "Paul" <pp@ltl-j.com> wrote in message
    news:%23iqMMz9l DHA.644@TK2MSFT NGP11.phx.gbl.. .[color=blue]
    > Hi there,
    >
    > I use datagrid to display my web page data and the first and the second
    > column's visible property is false.
    > How should I do if I want to get the first and second column's data ?
    > I use the following method, but failed...
    >
    > I.
    > CType(e.Item.Ce lls(0).Controls (0), TextBox).Text
    >
    > II.
    > e.Item.Cells(0) .Text
    >
    > --
    > PP
    >
    >[/color]


    Comment

    Working...