Use a value in my dataset as the "Text" of a buttoncolumn?

A

Arch

I have a data grid on my ASPX page that gets data from a dataset called
"Sites". My data grid has the following two columns:

<asp:ButtonColumn ButtonType = "LinkButton" CommandName="Select"
HeaderText="" Text="SiteName" />

<asp:boundcolumn headertext="Site ID" datafield="SiteID"
ItemStyle-Width="50px" />

I'd like to replace the Text property of my buttoncolumn from a fixed
string ("SiteName" in this example) to the dataset value "SiteID" that
is currently being used as the datafield property of my boundcolumn. My
idea is that I could get rid of my boundcolumn altogether if this value
was displayed in my buttoncolumn.

Can I do this? Any help is appreciated.
 
M

Mark Stevens

You can use the GridViews row data bound event and change the text
although you may still need a column holding the ID as you will need
to use this to change the text. Mind you, if you do still need it you
can make it invisible.

I think the general steps in the data bound event are:

1. Check to see if this is a header row or a data row.
2. If data row then find the link button control.
3. If the find control is not null then set the text.


Hope this helps,
Mark

I have a data grid on my ASPX page that gets data from a dataset called
"Sites". My data grid has the following two columns:

<asp:ButtonColumn ButtonType = "LinkButton" CommandName="Select"
HeaderText="" Text="SiteName" />

<asp:boundcolumn headertext="Site ID" datafield="SiteID"
ItemStyle-Width="50px" />

I'd like to replace the Text property of my buttoncolumn from a fixed
string ("SiteName" in this example) to the dataset value "SiteID" that
is currently being used as the datafield property of my boundcolumn. My
idea is that I could get rid of my boundcolumn altogether if this value
was displayed in my buttoncolumn.

Can I do this? Any help is appreciated.
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)

This message is provided "as is".
 
A

Arch

Mark, thanks for the reply. I need to fill in some gaps with Google (all
praises to the Google), but I'll proceed in the direction you've pointed
out.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top