Bug reports Found a bug? Post it here please.
Version 5.x > Bug reports > Asp.net standard grid events not getting fire View modes: 
User avatar
Member
Member
Aashish - 11/24/2010 12:49:36 AM
   
Asp.net standard grid events not getting fire
Hii

i am creating a ascx web part.In than web part i m using datagrid.
I dont knwo why that grid events not getting fired
Plz help
Thanx in advance

User avatar
Member
Member
kentico_michal - 11/24/2010 5:37:35 AM
   
RE:Asp.net standard grid events not getting fire
Hi,

Could you please describe your issue in more detail?

What exactly are you trying to achieve?

Would it be possible to post code of your web part?

Are you using Portal Engine or aspx templates?

Which version of Kentico CMS are you using?

Thank you in advance.


Best regards,
Michal Legen

User avatar
Member
Member
Aashish - 11/24/2010 8:19:45 AM
   
RE:Asp.net standard grid events not getting fire
i am trying to create a aspx web user control.

Here is cs file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.PortalControls;
using System.Data;

public partial class CMSWebParts_AMInstitute_SearchMemberProfile : CMSAbstractWebPart
{
protected void Page_Load(object sender, EventArgs e)
{
dgSearchResults.Visible = true;
if (!IsPostBack)
{
SetUI();

}

}

private void SetUI()
{
///
// Binding Grading DropDownList from 'EnumMembershipGrading'
///
int countMembershipGrading = Enum.GetNames(typeof(Common.EnumMembershipGrading)).Count();
for (int i = 0; i < countMembershipGrading; i++)
{
ddlGrading.Items.Add(new ListItem(Enum.GetNames(typeof(Common.EnumMembershipGrading)).Replace('_', ' ')));
}
ddlGrading.Items.Insert(0, "All Gradings");

///
// Binding Network Group DropDownList from 'EnumNetworkGroup'
///
int countNetworkGroup = Enum.GetNames(typeof(Common.EnumNetworkGroup)).Count();
for (int i = 0; i < countNetworkGroup; i++)
{
ddlNetworkGroup.Items.Add(new ListItem(Enum.GetNames(typeof(Common.EnumNetworkGroup)).Replace('_', ' ')));

}
ddlNetworkGroup.Items.Insert(0, "All Groups");

///
// Binding Organisations DropDownList from 'GetAllAMIOrganisation'
///
ddlOrganisation.DataSource = Common.GetAllOrganisations();
ddlOrganisation.DataTextField = "Name";
ddlOrganisation.DataValueField = "ID";
ddlOrganisation.DataBind();

///
// Binding States DropDownList from 'EnumStates'
///
int countStates = Enum.GetNames(typeof(Common.EnumStates)).Count();
for (int i = 0; i < countStates; i++)
{
ddlState.Items.Add(new ListItem(Enum.GetNames(typeof(Common.EnumStates)).Replace('_', ' ')));

}

}

protected void btnSearch_Click(object sender, EventArgs e)
{
string grading = string.Empty;
string networkGroup = string.Empty;
string givenName = string.Empty;
string surname = string.Empty;
string organisation = string.Empty;
string employmentPosition = string.Empty;
string address = string.Empty;
string suburb = string.Empty;
string state = string.Empty;
string postcode = string.Empty;

grading = ddlGrading.SelectedItem.Text;
networkGroup = ddlNetworkGroup.SelectedItem.Text;
if (txtGivenName.Text.Trim() != string.Empty)
{
givenName = txtGivenName.Text.Trim();
}
if (txtSurname.Text.Trim() != string.Empty)
{
surname = txtSurname.Text.Trim();
}
organisation = Convert.ToString(ddlOrganisation.SelectedValue);
if (txtEmploymentPosition.Text.Trim() != string.Empty)
{
employmentPosition = txtEmploymentPosition.Text.Trim();
}
if (txtAddress.Text.Trim() != string.Empty)
{
address = txtAddress.Text.Trim();
}
if (txtSuburb.Text.Trim() != string.Empty)
{
suburb = txtSuburb.Text.Trim();
}
state = ddlState.SelectedItem.Text;
if (txtPostcode.Text.Trim() != string.Empty)
{
postcode = txtPostcode.Text.Trim();
}
if (ddlGrading.SelectedItem.Text == "All Gradings" || ddlNetworkGroup.SelectedItem.Text == "All Groups")
{
dgSearchResults.DataSource = Common.SearchProfileResults(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
dgSearchResults.DataBind();

}
else
{
dgSearchResults.DataSource = Common.SearchProfileResults(grading, networkGroup, givenName, surname, organisation, employmentPosition, address, suburb, state, postcode);
dgSearchResults.DataBind();
}


}


protected void dgSearchResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
Response.Redirect("aashish");
}
}


Here is my ascx file

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchMemberProfile.ascx.cs"
Inherits="CMSWebParts_AMInstitute_SearchMemberProfile" %>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
<table class="style1">
<tr>
<td>
<table class="style1">
<tr>
<td>
<h1>
Profile Search
</h1>
</td>
<td>
 
</td>
<td>
 
</td>
</tr>
<tr>
<td>
 
</td>
<td>
 
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Grading:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlGrading" runat="server">
</asp:DropDownList>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Network Group:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlNetworkGroup" runat="server">
</asp:DropDownList>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Given Name:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtGivenName" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Surname:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtSurname" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Organisation:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlOrganisation" runat="server">
</asp:DropDownList>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="Employment Position:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmploymentPosition" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="Address:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label8" runat="server" Text="Suburb:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtSuburb" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label9" runat="server" Text="State:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlState" runat="server">
</asp:DropDownList>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label10" runat="server" Text="Postcode:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPostcode" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
 
</td>
<td>
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
</td>
<td>
 
</td>
</tr>
<tr>
<td>
 
</td>
<td>
 
</td>
<td>
 
</td>
</tr>
</table>
<table class="style1">
<tr>
<td>
<asp:GridView ID="dgSearchResults" runat="server" AutoGenerateColumns="False" OnRowCommand="dgSearchResults_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>

</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FirstName" HeaderText="Given Name" />
<asp:BoundField DataField="Surname" HeaderText="Surname" />
<asp:BoundField DataField="Name" HeaderText="Organisation" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
</table>


Now on clicking LinkButton in datagrid , datagrid RowCommand Event should fire.But its is not getting fired.

Please help me to move out of this issue

Thanks in advance



User avatar
Member
Member
kentico_michal - 11/29/2010 8:40:55 AM
   
RE:Asp.net standard grid events not getting fire
Hi,


Please make sure that viewstate is enabled and also please try to use following Page_Load method:

protected void Page_Load(object sender, EventArgs e)
{
dgSearchResults.Visible = true;
SetUI();
}



Best regards,
Michal Legen

User avatar
Member
Member
Aashish - 12/6/2010 1:45:25 AM
   
RE:Asp.net standard grid events not getting fire
Thanks Michal...after enabling the viewstate...code is working fine

User avatar
Member
Member
saikhuan - 6/27/2011 7:48:28 AM
   
RE:Asp.net standard grid events not getting fire
Hi.. I have the same problem. Where did you enable viewstate? Is it from kentico?

User avatar
Member
Member
kentico_michal - 6/28/2011 1:27:42 AM
   
RE:Asp.net standard grid events not getting fire
Hello,

The ViewState is a general feature included in ASP.NET. I would like to point you to the following forums with similar issue described:
- GridView RowCommand Not Firing
- RowCommand not firing whenViewState disabled

If it does not help, could you please try to use the User control web part for including the user control on the page: User control


Best regards,
Michal Legen