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

  • Thread starter Thread starter Arch
  • Start date Start date
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.
 
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".
 
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.
 
Back
Top