473,326 Members | 2,124 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,326 software developers and data experts.

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.Columns.AddAt(0, bc)

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

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

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

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand="SeeDetails"
AutoGenerateColumns="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 1692
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.Columns.AddAt(0, bc)

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

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

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

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand="SeeDetails"
AutoGenerateColumns="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****************@TK2MSFTNGP10.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.Columns.AddAt(0, bc)

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

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

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand="SeeDetails"
AutoGenerateColumns="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*@discussions.microsoft.com> escreveu na mensagem
news:77**********************************@microsof t.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.Columns.AddAt(0, bc)

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

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

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

In HTML have this:

------------------------------------
<asp:datagrid id="dgMyGrid" OnItemCommand="SeeDetails"
AutoGenerateColumns="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
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
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...
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...
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...
5
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...
4
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...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.