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
|