EDN Admin
Well-known member
Hi folks, here i am trying to figure out a bug in my code and would appreciate it if another pair of eyes can look at it and let me know if i am missing something that is preventing the OnSelectedIndexChanged event from being fired. I have a GridView called
DetailsGridView which i try to populate based on the index selected. The index selected here is a specific JobId. The OnSelectedIndexChanged event just doesnt get fired on selection. Here pieces of code that i am using..
<span style="text-decoration:underline ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ManageImportJobs.aspx.cs" Inherits="ManageImportJobs" MasterPageFile="~/MasterPage.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" runat="Server
Filter:
<asp:UpdateProgress ID="UpdateProgress1" runat="server
<ProgressTemplate>
<img alt="Processing..." src="ajax-loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel" runat="server
<ContentTemplate>
<asp:TextBox id="FilterTextBox" runat="server" />
<asp:Button id="ApplyFilterButton" runat="server" Text="Apply Filter" OnClick="ApplyFilterButton_Click" />
<asp:GridView ID="SummaryGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="JobId"
DataSourceID="JobSummaryDataSource" CellPadding="4" ForeColor="#333333" GridLines="None"
OnSelectedIndexChanged="SummaryGridView_SelectedIndexChanged" PageSize="25"
OnRowDeleted="SummaryGridView_RowDeleted
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField ShowHeader="False
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick="return confirm(Are you sure you want to revert this import job?);"
Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="JobId" HeaderText="JobId" SortExpression="JobId" />
<asp:BoundField DataField="ImportJobLabel" HeaderText="ImportJobLabel" SortExpression="ImportJobLabel" />
<asp:BoundField DataField="ImportDateTime" HeaderText="ImportDateTime" SortExpression="ImportDateTime" />
<asp:BoundField DataField="ImportedBy" HeaderText="ImportedBy" SortExpression="ImportedBy" />
<asp:CheckBoxField DataField="IsEstimate" HeaderText="IsEstimate" SortExpression="IsEstimate" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="JobSummaryDataSource" runat="server"
DeleteMethod="RevertImportJob"
<span style="white-spacere SelectMethod="ListJobSummaryWithFilter"
TypeName="DSADataService.DSADataServiceClient" EnablePaging="True"
MaximumRowsParameterName="pageSize" SelectCountMethod="CampaignSpendingImportJobCountWithFilter"
StartRowIndexParameterName="startIndex"
DataObjectTypeName="DSADataContracts.CampaignSpendingImportJob
<SelectParameters>
<asp:ControlParameter ControlID="FilterTextBox" PropertyName="Text" Name="filterPattern" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<br />
<br />
<asp:GridView ID="DetailsGridView" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="RowPrefix" HeaderText="RowPrefix" SortExpression="RowPrefix" />
<asp:BoundField DataField="Count" HeaderText="Count" SortExpression="Count" DataFormatString="{0:#,##0}" />
<asp:BoundField DataField="Spend" HeaderText="Spend" SortExpression="Spend" DataFormatString="{0:c}" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</asp:Content>
<span style="text-decoration:underline ASPX.CS:
public partial class ManageImportJobs : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SummaryGridView_SelectedIndexChanged(object sender, EventArgs e)
{
var selectedImportJobId = (int)SummaryGridView.SelectedValue;
using (var service = new DSADataService.ZooskDataServiceClient())
{
var jobDetailRows = CampaignSpendingImportJobDetailsRow.GetJobDetailRows(service.ListCampaignSpendsByJobId(selectedImportJobId));
DetailsGridView.DataSource = jobDetailRows;
DetailsGridView.DataBind();
}
}
Any help is much appreciated. Thanks for reading
View the full article
DetailsGridView which i try to populate based on the index selected. The index selected here is a specific JobId. The OnSelectedIndexChanged event just doesnt get fired on selection. Here pieces of code that i am using..
<span style="text-decoration:underline ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ManageImportJobs.aspx.cs" Inherits="ManageImportJobs" MasterPageFile="~/MasterPage.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" runat="Server
Filter:
<asp:UpdateProgress ID="UpdateProgress1" runat="server
<ProgressTemplate>
<img alt="Processing..." src="ajax-loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel" runat="server
<ContentTemplate>
<asp:TextBox id="FilterTextBox" runat="server" />
<asp:Button id="ApplyFilterButton" runat="server" Text="Apply Filter" OnClick="ApplyFilterButton_Click" />
<asp:GridView ID="SummaryGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="JobId"
DataSourceID="JobSummaryDataSource" CellPadding="4" ForeColor="#333333" GridLines="None"
OnSelectedIndexChanged="SummaryGridView_SelectedIndexChanged" PageSize="25"
OnRowDeleted="SummaryGridView_RowDeleted
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField ShowHeader="False
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick="return confirm(Are you sure you want to revert this import job?);"
Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="JobId" HeaderText="JobId" SortExpression="JobId" />
<asp:BoundField DataField="ImportJobLabel" HeaderText="ImportJobLabel" SortExpression="ImportJobLabel" />
<asp:BoundField DataField="ImportDateTime" HeaderText="ImportDateTime" SortExpression="ImportDateTime" />
<asp:BoundField DataField="ImportedBy" HeaderText="ImportedBy" SortExpression="ImportedBy" />
<asp:CheckBoxField DataField="IsEstimate" HeaderText="IsEstimate" SortExpression="IsEstimate" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="JobSummaryDataSource" runat="server"
DeleteMethod="RevertImportJob"
<span style="white-spacere SelectMethod="ListJobSummaryWithFilter"
TypeName="DSADataService.DSADataServiceClient" EnablePaging="True"
MaximumRowsParameterName="pageSize" SelectCountMethod="CampaignSpendingImportJobCountWithFilter"
StartRowIndexParameterName="startIndex"
DataObjectTypeName="DSADataContracts.CampaignSpendingImportJob
<SelectParameters>
<asp:ControlParameter ControlID="FilterTextBox" PropertyName="Text" Name="filterPattern" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<br />
<br />
<asp:GridView ID="DetailsGridView" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="RowPrefix" HeaderText="RowPrefix" SortExpression="RowPrefix" />
<asp:BoundField DataField="Count" HeaderText="Count" SortExpression="Count" DataFormatString="{0:#,##0}" />
<asp:BoundField DataField="Spend" HeaderText="Spend" SortExpression="Spend" DataFormatString="{0:c}" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</asp:Content>
<span style="text-decoration:underline ASPX.CS:
public partial class ManageImportJobs : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SummaryGridView_SelectedIndexChanged(object sender, EventArgs e)
{
var selectedImportJobId = (int)SummaryGridView.SelectedValue;
using (var service = new DSADataService.ZooskDataServiceClient())
{
var jobDetailRows = CampaignSpendingImportJobDetailsRow.GetJobDetailRows(service.ListCampaignSpendsByJobId(selectedImportJobId));
DetailsGridView.DataSource = jobDetailRows;
DetailsGridView.DataBind();
}
}
Any help is much appreciated. Thanks for reading
View the full article