Hi,
I have the following gridview in aspx:
<asp:GridView ID="list" runat="server" AutoGenerateColumns="False"
DataKeyNames="pid" onrowcommand="ListGridView_RowCommand"
SelectedRowStyle-HorizontalAlign="NotSet">
<Columns>
<asp:BoundField DataField="type" />
<asp:BoundField DataField="approved" />
<asp:BoundField DataField="pid"
HeaderText="pid" />
<asp:TemplateField HeaderText="Commands">
<ItemTemplate>
<asp:Button runat="server" ID='EB'
Text="Edit" CommandName="EB" ></asp:Button>
<asp:Button runat="server" ID='A'
Text="Approve" CommandName="A" CommandArgument='<%#Eval("id") %>' ></
asp:Button>
<asp:Button runat="server" ID='H'
Text="Hide" CommandName="H" CommandArgument='<%# CType(Container,
GridViewRow).RowIndex %>' ></asp:Button>
<asp:Button runat="server" ID='DC'
Text="Delete" CommandName="DC" OnClientClick="return confirm('This
will delete the comment. Do you want to proceed?')"></asp:Button>
<asp:Button runat="server" ID='DB'
Text="Delete" CommandName="DB" OnclientClick="return confirm('This
will delete the blog AND the comments associated with the blog. Do you
want to proceed?')" ></asp:Button>
</ItemTemplate>
</asp:TemplateField>
and the vb code:
Public Sub ListGridView_RowCommand(ByVal sender As Object, ByVal e As
GridViewCommandEventArgs)
' If multiple buttons are used in a GridView control, use the
' CommandName property to determine which button was clicked.
Response.Redirect("yaho.co")
Session("result") = e.CommandName.ToString
If (e.CommandName = "EB") Then
' Convert the row index stored in the CommandArgument
' property to an Integer.
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
' Retrieve the row that contains the button clicked
' by the user from the Rows collection.
Dim row As GridViewRow = list.Rows(index)
pnlAdd.Visible = True
'title.Text = row.FindControl("title").ToString
'FTB_FreeTextBox2122.Text =
row.FindControl("message").ToString
Session("result") = "EB"
ElseIf (e.CommandName = "A") Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = list.Rows(index)
pnlAdd.Visible = True
Session("result") = "A"
ElseIf (e.CommandName = "H") Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = list.Rows(index)
pnlAdd.Visible = True
Session("result") = "H"
ElseIf (e.CommandName = "DC") Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = list.Rows(index)
ElseIf (e.CommandName = "DB") Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = list.Rows(index)
End If
End Sub
and clicking either button does nothing but post back the page. pnlAdd
does not show up, nor is Session("result") populated.
I have tried different methods for the buttons themselves, but none
work.
Can anyone see what I am missing in the code?
Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---