473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ButtonColumn

I have a datagrid with a ButtonColumn and a BoundColumn with a value.
Without showing the value, how can I make the button send back the value?
Nov 18 '05 #1
1 1722
Hi Roger,

By using a template column you can accomplish your goal without needing the
hidden BoundColumn at all. It is just a matter of putting the value into the
CommandArgument like this:
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton runat="server" Text="Get Value"
CommandName="GetValue" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "IntegerValue") %>'
CausesValidation="false">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
</form>

Then, when the button is clicked, you can pick up the value from the
CommandArgumentand do whatever you need to do:

Private Sub DataGrid1_ItemCommand _
(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls. _
DataGridCommandEventArgs) _
Handles DataGrid1.ItemCommand
If e.CommandName = "GetValue" Then
Label1.Text = e.CommandArgument.ToString
End If
End Sub

Ken
MVP [ASP.NET]

"Roger" <so*****@microsoft.com> wrote in message
news:em*************@tk2msftngp13.phx.gbl...
I have a datagrid with a ButtonColumn and a BoundColumn with a value.
Without showing the value, how can I make the button send back the value?


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan | last post by:
Hi everyone, i am having a problem with some parameters. I got a datagrid with several columns. My first column is hidden and contains a unique ID for a member. My last column is a buttonColumn....
4
by: CGuy | last post by:
Hi, I have a datagrid that has one ButtonColumn which is bound to a database field. My requirement is that when the page containing the datagrid is loaded, I would like the ButtonColumn to be...
3
by: John | last post by:
The ItemCommand event not getting fired when I add both a BoundColumn and a ButtonColumn to a datagrid. When I add a ButtonColumn by itself, everything works fine, but as soon as I add a...
6
by: z. f. | last post by:
Hi, i have a datagrid with a delete button for each row in the grid. when the delete button is clicked i need to ask the user in a "confirm" message box if he's sure he wants to delete. the...
3
by: ruca | last post by:
Hi gurus, I need to create a ButtonColumn in my code for using in my datagrig. What happens is that I create this button in code, but then when I click him, nothing happens. I have this in my...
1
by: Lenin Sakthees via .NET 247 | last post by:
Hi all, I am using a datagrid to show values from a SQL table. My problem is, I want to show the details of the each row when the user clicks the 'View details' buttoncolumn. I am able to fire a...
2
by: John Mason | last post by:
Hi, I have a datagrid of invoices with a buttoncolumn that users can click on to pay a particular invoice. Once the invoice is paid, the datagrid is reloaded, however, the button to pay the...
1
by: Sathyaish | last post by:
How do you get the text of a ButtonColumn control column in a datagrid? As an example, I tried this little snippet on a test project, but it returns a null string. Private Sub...
1
by: Dave | last post by:
On a web form I have a grid, grid1, with a ButtonColumn bound to a field in a table. When the button is clicked I want do do something with the data view in the row clicked. How do I retrieve the...
1
by: nipe | last post by:
Hello, I'm having problem with my custom datagrid control can't fire itemcommand event. The fact is that I have to make fully cutom user control so I can't do any scripting to .aspx file. There...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.