hidden columns that contain a "key" field

B

Boban Dragojlovic

I've seen several examples where people include a "key" column in the
datagrid so that they know which row to update during the update phase.

The examples I've seen look like this:

<asp:BoundColumn Visible=True DataField="ID"
HeaderText="ID"></asp:BoundColumn>

When I do this in my own form, the column is not only not visible, but it is
not sent to the browser.

How can I get it to be sent, but remain hidden?
 
S

Saravana [MVP]

You didnt include runtat attribute for boundcolumn, if didnt include that it
wont get processed in server. Include that see, it should work.
 
B

bspann

Boban,

Like Saravana states, you must have the runat attribute set on the datagrid.
Then under the <Columns> tag, include a
<asp:BoundColumn Visible=False DataField="ID"></asp:BoundColumn>
You must have a field in whatever you used to bind to the grid called "ID".
If that field does not exist, you will either get an error or the field will
not be included.

If you are wanting to include the "ID" value appended to an URL that the
user clicks, use the following code:
<asp:TemplateColumn HeaderText="SomeText">
<ItemTemplate>
<a href=http://www.yoursite.com/application/page.aspx?id= <%#
DataBinder.Eval(Container.DataItem, "ID") %> >Some Text</a>
</ItemTemplate>
</asp:TemplateColumn>

That should get you started. Please post any questions.

Thanks,

Brian
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top