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

Home Posts Topics Members FAQ

Create DataGrig ButtonColumn Dinamically

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 vb code:
---------------------------------
Dim bc As New ButtonColumn
bc.HeaderText = ""
bc.Text = "See Details"
bc.CommandName = "Select"
dgMyGrid.Column s.AddAt(0, bc)

//then I have the fucntion that should run when click in button
Sub SeeDetails(ByVa l Sender As Object, ByVal e As DataGridCommand EventArgs)

If e.CommandName <> "Page" Then
'Place my code here
End If

End Sub
------------------------------------

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand=" SeeDetails"
AutoGenerateCol umns="False">
......
</asp:datagrid>
------------------------------------
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
Nov 19 '05 #1
3 1706
Vko
Try to :
- add an ID to your button.
- move your code into the OnInit method.

"ruca" wrote:
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 vb code:
---------------------------------
Dim bc As New ButtonColumn
bc.HeaderText = ""
bc.Text = "See Details"
bc.CommandName = "Select"
dgMyGrid.Column s.AddAt(0, bc)

//then I have the fucntion that should run when click in button
Sub SeeDetails(ByVa l Sender As Object, ByVal e As DataGridCommand EventArgs)

If e.CommandName <> "Page" Then
'Place my code here
End If

End Sub
------------------------------------

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand=" SeeDetails"
AutoGenerateCol umns="False">
......
</asp:datagrid>
------------------------------------
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 19 '05 #2
Check out this article to know how to add columns dynamically to datagrid
Creating Datagrid Templated Columns Dynamically
http://www.dotnetbips.com/displayarticle.aspx?id=84
http://www.dotnetbips.com/displayarticle.aspx?id=85
--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"ruca" <ru***@iol.pt > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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 vb code:
---------------------------------
Dim bc As New ButtonColumn
bc.HeaderText = ""
bc.Text = "See Details"
bc.CommandName = "Select"
dgMyGrid.Column s.AddAt(0, bc)

//then I have the fucntion that should run when click in button
Sub SeeDetails(ByVa l Sender As Object, ByVal e As DataGridCommand EventArgs)
If e.CommandName <> "Page" Then
'Place my code here
End If

End Sub
------------------------------------

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand=" SeeDetails"
AutoGenerateCol umns="False">
......
</asp:datagrid>
------------------------------------
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 19 '05 #3
This is ASP.NET and buttoncolumn don't have Id's.
And don't have OnInit method. Have Form_Load event.
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Vko" <Vk*@discussion s.microsoft.com > escreveu na mensagem
news:77******** *************** ***********@mic rosoft.com...
Try to :
- add an ID to your button.
- move your code into the OnInit method.

"ruca" wrote:
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 vb code:
---------------------------------
Dim bc As New ButtonColumn
bc.HeaderText = ""
bc.Text = "See Details"
bc.CommandName = "Select"
dgMyGrid.Column s.AddAt(0, bc)

//then I have the fucntion that should run when click in button
Sub SeeDetails(ByVa l Sender As Object, ByVal e As
DataGridCommand EventArgs)

If e.CommandName <> "Page" Then
'Place my code here
End If

End Sub
------------------------------------

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand=" SeeDetails"
AutoGenerateCol umns="False">
......
</asp:datagrid>
------------------------------------
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 19 '05 #4

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

Similar topics

0
1508
by: Kepes Krisztian | last post by:
Hi ! My problem is that: 1.) I want to create a frame with some buttons, and client area. If the user clicked on a button, the procedure create components on client area, and show results.
4
3203
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 enabled/disabled based on the value of a boolean variable that is calculated at runtime - if the value if false, I don't want the ButtonColumn to...
3
2350
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 BoundColumn, the ItemCommand event doesn't seem to get called. I've been struggling with this for too long now, I'm certain there's something I'm not...
6
3143
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 problem is that the <asp:ButtonColumn ButtonType="PushButton" CommandName="Delete" .... don't have a property to allow onclick to run client side...
1
3395
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 event when the user clicks the button column here is my html for the datagrid...
1
1566
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 dg_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.ItemCommand If Not e.Item Is Nothing Then...
5
1284
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 vb code: --------------------------------- Dim bc As New ButtonColumn bc.HeaderText = "" bc.Text = "See Details"
4
1328
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I can create the label and the webcontrol dinamically with no errors, but only the Label appear in the panel when the page is shown in the client...
1
1700
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 are two classes that has something to do with this: datagrid class which has 2 buttoncolumns and panel class that HAS datagrid and handles...
0
7912
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
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
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
6614
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...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3837
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...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.