Still looking for an answer

G

Guest

Hi
I have a web form with a Datagrid. Within the data grid I have a Column
button. If the button is of type "Linkbutton" my VB code-behind will catch
the users
"click"
However, if it is set to "Pushbutton" I am unable to trap the users
click. See code Below.
I don't understand what I am missing. why won't the
"Pushbutton" work?

VB code Behind:
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.ItemCommand
'get value of row here
End Sub

HTML:
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 80px; POSITION:
absolute; TOP: 140px" runat="server" Width="484px">
<Columns>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select"></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
</form>
</body>

Thanks
Brian
 
H

Herfried K. Wagner [MVP]

Brian,

BrianDH said:
I have a web form with a Datagrid. Within the data grid I have a Column
button. If the button is of type "Linkbutton" my VB code-behind will
catch
the users
"click"
However, if it is set to "Pushbutton" I am unable to trap the users
click. See code Below.

Notice that there is a separate group for the ASP.NET datagrid available:

<URL:
 
G

Guest

Yes but I am not doing ASP this is a web form run by VB code-behind? The
event would be traped by server side VB.Net code not ASP, client side code.

ButI'll try there too.
 
L

Lucas Tam

Yes but I am not doing ASP this is a web form run by VB code-behind?
The event would be traped by server side VB.Net code not ASP, client
side code.

It's ASP.NET, not VB.NET Winforms. You better get your terminology
straightened out ; )
 
C

Cor Ligthert

Lucas,

I do not see what is wrong in the terminologie from Brian, as well not in
the message from Herfried by the way.

That group is special for the Webform Datagrid, in that there is not much
difference between VBNet scripting or VBNet for Dll.

The only problem is that there are almost no answers given in that newsgroup
at least the last 4 days.

Cor
 
L

Lucas Tam

I do not see what is wrong in the terminologie from Brian, as well not
in the message from Herfried by the way.

That group is special for the Webform Datagrid, in that there is not
much difference between VBNet scripting or VBNet for Dll.

Herfried was right to redirect the question to the Webforms group...
because the datagrid in ASP.NET functions very different than the winforms
datagrid. But I don't think the original poster realizes the difference...
or perhaps I misinterpreted his answer.
 
H

Herfried K. Wagner [MVP]

Lucas Tam said:
Herfried was right to redirect the question to the Webforms group...

I didn't redirect anybody. I only provided a suggestion.
 
G

Guest

I understand the difference.
However this is the only group you can find an answer in.
I Agree that it is an ASP form but all the code I am using is VB.Net server
side code behind, not code within the HTML part of the application.
So since this is the VB.Net NG I placed my question here.
But I am not a highly educated programmer I am a self-taught retired
musician looking for a little help.
I apologize if I did or said something wrong.

B
 
C

Cor Ligthert

Brian,

Did you load your datagrid with data?
With me did it work fine,

You can try it.
\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
builddata()
DataGrid1.DataBind()
Else
builddata()
End If
End Sub
Private Sub builddata()
Dim dt As New DataTable
dt.Columns.Add("Column1")
For i As Integer = 0 To 9
Dim dr As DataRow = dt.NewRow
dr(0) = i.ToString
dt.Rows.Add(dr)
Next
DataGrid1.DataSource = dt
End Sub
Private Sub DataGrid1_ItemCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles DataGrid1.ItemCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub
///

I hope this helps?

Cor
 
C

Cor Ligthert

Lucas

There is for the windowforms datagrid as well a special newsgroup

microsoft.public.dotnet.languages.vb.controls

However that datagrid is as well answered here.
And I see not any problems for both in that.

For draging a datagrid to a form there is no newsgroup needed.

The problems come when how you implement the language.vb code.

Just my thought

Cor
 
L

Lucas Tam

I understand the difference.
However this is the only group you can find an answer in.
I Agree that it is an ASP form but all the code I am using is VB.Net
server side code behind, not code within the HTML part of the
application. So since this is the VB.Net NG I placed my question
here. But I am not a highly educated programmer I am a self-taught
retired musician looking for a little help.
I apologize if I did or said something wrong.


I found microsoft.public.dotnet.framework.aspnet to be very helpful. Lots
of traffic there (and since it's dedciated to ASP.NET, they may know the
answer).

As for your problem with the pushbutton - I never had that problem myself.
The code I used is practically identical to yours and it works fine on my
end.
 
G

Guest

Yes as a metter of fact I have working Web Application that work just fine.
Thats why I ask "what am I missing?" I started a new project, added a
datagrid, called the same web-service that another one of my projects uses.
Populated the grid with the same data, have one column with a button just
like my working application but it fails to call when the button is of type
"PushButton"
Very darn odd! I just thought i was forgetting a namespace or needed to
place a handler somewhere but I can't find anything that points to the
problem.

I will try your example and let you know !

Thanks ;-)
Brian
 
L

Lucas Tam

Yes as a metter of fact I have working Web Application that work just
fine. Thats why I ask "what am I missing?" I started a new project,
added a datagrid, called the same web-service that another one of my
projects uses. Populated the grid with the same data, have one column
with a button just like my working application but it fails to call
when the button is of type "PushButton"
Very darn odd! I just thought i was forgetting a namespace or needed
to place a handler somewhere but I can't find anything that points to
the problem.


An idea - are you rebinding the datagrid on each load? I think if you do...
that may invalidate the pushbutton.
 
G

Guest

Cor, you example works fine. My other application works fine. I started a
new project, with a new web form-datagrid-WS call-and code. It works fine.
My best guess is there is/was somthing messed up about that project.

Lucas, Yes that could be, but i only call for the dataset on the first load
i use the "Is Post Back" to filter my events on post back.

I am going to do a little more R&D and will post to all what error i have
made here when i am sure.

Thanks you all for the HELP!
BrianDH
P.S. you might want to see why no one eve answers over on the
Framework.Datagrid NG
 
G

Guest

OK, its just this one project, I have no idea why the code fails to work so
I saved my .vb files and dumped the project. Never thought to try that.

Anyway it works now!

I thank you all!

BrianDH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top