473,586 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the text of the ButtonColumn

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 dg_ItemCommand( ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dg.ItemCommand
If Not e.Item Is Nothing Then
lblMessage.Text = "You clicked " & e.Item.Cells(1) .Text &
"."
End If
End Sub
where the column clicked is of type ButtonColumn and it is the second
column (index 1) in the row.

<asp:ButtonColu mn DataTextField=" Full Name" HeaderText="Ful l
Name"></asp:ButtonColum n>

I also tried:

Dim lbl As HyperLink = CType(e.Item.Ce lls(1).Controls (0), HyperLink)
lblMessage.Text = "You clicked " & lbl.Text & "."

but it said that the specified cast is not valid.

Nov 19 '05 #1
1 1565
Try casting as a LinkButton

Nov 19 '05 #2

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

Similar topics

3
1705
by: Mark Jones | last post by:
Hi All, I'm currently having difficulty putting the text from a selected link in a ButtonColumn from a DataGrid into a cookie. The idea is that a user selects a group link from this column and is taken to the group page, where the group link they have just selected is used to populate the page with the relevant group information from the...
1
3853
by: Daniel Bass | last post by:
this was working Dim szMsgNumber = db_grid.SelectedItem.Cells(0).Text until i changed the first column (at index 0) to a ASP:ButtonColumn from a boundcolumn...
1
1613
by: MS Newsgroups | last post by:
Hi, I am new to the datagrid and I am trying to figure out how to get the text string from the cell when a bound linkbutton is clicked. According to the documentation, I should the Itemcommand event and should be able to get this value from e.items.cells(0).text For the current string in the first column in the clicked row, but I...
2
2831
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added to it to view additional details about the selected result (a second database query is triggered). I want this second query to pop up in a new...
1
2684
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting, paginantion or accepting the add and remove item events. What i am observing is that none of the vents are happening... (Sort, page, or item). I am sure I...
1
972
by: Billow | last post by:
Hello I'd like to change the text of cells of a column which has been set as a buttonColumn and bounded to a datafield. I have tried to change its texts with code,but met a setback. Beneath here is what I have tried: hyst=menuDataGrid.Items.Cells.Text; //------hyst=""----The returned string was empty, why?...
1
3900
by: Ben | last post by:
Hi there, I would like to change the text of the ButtonColumn after datagrid binding, depending on the value of a certain field. (eg. Text="Details" for case 1, Text="others' for case 2) Is it possible to do so? <asp:datagrid id="dgList" runat="server" Width="890" BorderStyle="None" GridLines="Both" BorderWidth="1px" ...
0
1049
by: crferguson | last post by:
Hello all! I have a simple datagrid bound to a datatable with three columns in it. The first column is a buttoncolumn bound to the first column in the datatable which causes the text on the buttons to show the values in the datatable column. What I'm trying to do is, upon the user clicking one of the buttons in the buttoncolumn, get the...
0
1746
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid for editing and deleting data. When a user clicks on the "Edit" button in the datagrid, Edit() method is called and the appropriate row is changed...
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.