DataGrid hidden field

Discussion in 'ASP .Net' started by Maziar Aflatoun, May 9, 2004.

  1. Hi everyone,

    I have the following code and I like to add a hidden field in each row

    <asp:datagrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 48px; POSITION:
    absolute; TOP: 40px" runat="server"
    AutoGenerateColumns="False" >
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:Checkbox ID="chkSelection" Runat="server"></asp:Checkbox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="FirstName"
    HeaderText="FirstName"></asp:BoundColumn>
    <asp:BoundColumn DataField="LastName"
    HeaderText="LastName"></asp:BoundColumn>
    </Columns>
    </asp:datagrid>

    Ex. something like
    <asp:BoundColumn DataField="FirstName"
    HeaderText="FirstName"></asp:BoundColumn>
    <asp:BoundColumn DataField="LastName"
    HeaderText="LastName"></asp:BoundColumn>
    <input type="hidden" name="myhidden" value="<%#
    DataBinder.Eval(Container.DataItem, "RowID") %>" runat=server"> which
    doesn't work

    Any idea?

    Thank you
    Maz.
     
    Maziar Aflatoun, May 9, 2004
    #1
    1. Advertising

  2. Maziar Aflatoun

    Klas L Guest

    Try to add something like this in Page_Load:

    DataGrid1.tables(0).columns(4).visible = false

    /Klas

    >-----Original Message-----
    >Hi everyone,
    >
    >I have the following code and I like to add a hidden
    >field in each row
     
    Klas L, May 9, 2004
    #2
    1. Advertising

  3. Add a Databound column to the grid with attribute: visible = false like this

    <asp:BoundColumn DataField="RowID" HeaderText="RowID" visible="False"></asp:BoundColumn>
     
    =?Utf-8?B?RGFuIEI=?=, May 9, 2004
    #3
  4. As far as I remember, setting visible="False" results in not sending the
    column to the client. If you want the column to get sent to the client. hide
    is with a style rule like this:
    <head>
    ....
    <style type="text/css">
    ..Invisible {display:none}
    </style>
    ....
    </head>
    <body>
    ....
    <asp:BoundColumn DataField="RowID" >
    <ItemStyle CssClass="Invisible"></ItemStyle>
    </asp:BoundColumn>
    ....
    </body>

    Eliyahu

    "Dan B" <> wrote in message
    news:...
    > Add a Databound column to the grid with attribute: visible = false like

    this:
    >
    > <asp:BoundColumn DataField="RowID" HeaderText="RowID"

    visible="False"></asp:BoundColumn>
     
    Eliyahu Goldin, May 10, 2004
    #4
  5. If you want to reach the field at client, use <TemplateItem> with <input type=hidden>
     
    =?Utf-8?B?RGFuIEI=?=, May 10, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Not Me
    Replies:
    2
    Views:
    590
    Not Me
    Feb 8, 2005
  2. Rick
    Replies:
    3
    Views:
    8,193
    Alexey Smirnov
    Apr 13, 2010
  3. GavMc
    Replies:
    4
    Views:
    340
    Evertjan.
    Sep 22, 2005
  4. Roy Adams

    writing from hidden field to text field

    Roy Adams, Dec 20, 2004, in forum: Javascript
    Replies:
    1
    Views:
    197
  5. Roy Adams
    Replies:
    3
    Views:
    269
    Dr John Stockton
    Dec 21, 2004
Loading...

Share This Page