How avoid Dropdownlist page regreshing in asp.net
hi,I have two div one div for search creteria and another for Datagrid
to showing current status of data. Also I have included timer for data fresh
in gridview.
My basic problem is when i select dropdownlist that time my gridview is getting
refresh. In gridview have using grouping.So suddenly changes in group in without
grouping after selected dropdownlist on selectedindexchange. I dont want such type
of behaviour.
<asp:UpdatePanel ID="upsReport" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="bFind" />
<asp:AsyncPostBackTrigger ControlID="ddlProjectName" EventName="SelectedIndexChanged" />
<asp:PostBackTrigger ControlID="dgTollData" />
</Triggers>
<ContentTemplate>
<div class="container" style="margin-top: -2.5%;">
<div class="row">
<div class="widget" id="dSearchCreateria" runat="server">
<div class="widget-header">
<h3>
Toll Monitoring</h3>
</div>
<div class="widget-content">
<div class="row">
<div class="col-md-12">
<div class="form-horizontal" role="form">
<div class="col-sm-3">
<b>Project Name</b><span style="color: Red; font-weight: bolder; font-size: medium;">*</span>
<asp:DropDownList ID="ddlProjectName" AutoPostBack="true" CssClass="form-control"
runat="server" TabIndex="1" Style="color: Maroon; font-weight: bold;" OnSelectedIndexChanged="ddlProjectName_SelectedIndexChanged">
</asp:DropDownList>
</div>
<div class="col-sm-3">
<b>Toll Name</b>
<asp:DropDownList ID="ddlTollName" Style="color: Maroon; font-weight: bold;" AutoPostBack="true"
CssClass="form-control" runat="server" TabIndex="2" OnSelectedIndexChanged="ddlTollName_SelectedIndexChanged">
</asp:DropDownList>
</div>
<div class="col-sm-2">
<b>Start Date</b><span style="color: Red; font-weight: bolder; font-size: medium;">*</span>
<asp:TextBox ID="tbStartDate" CssClass="form-control" runat="server" TabIndex="3"
Style="font-family: Verdana; background-color: White; color: Maroon; font-weight: bold;"></asp:TextBox>
</div>
<div class="col-sm-1">
<asp:Image ID="ibStartDate" runat="server" ImageUrl="~/Image/Calendar.png" Height="30px"
Width="30px" Style="margin-top: 20px; float: left;" />
<asp:CalendarExtender ID="ceStartDate" runat="server" Format="dd-MM-yyyy" TargetControlID="tbStartDate"
PopupButtonID="ibStartDate">
</asp:CalendarExtender>
</div>
<div class="col-sm-1">
<asp:Button ID="bFind" runat="server" TabIndex="4" Width="50px" Text="Find" Style="height: 30px;
margin-top: 25px; color: White !important; background-color: #293339 !important;
-webkit-print-color-adjust: exact;" OnClick="bFind_Click" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="dTollAnalysisReport" runat="server" visible="true">
<div class="col-md-11">
<div id="no-more-tables">
<div class="row">
<asp:DataGrid ID="dgTollData" runat="server" AutoGenerateColumns="false" GridLines="None"
CssClass="table table-hover table-bordered table-striped" OnItemCreated="dgTollData_ItemCreated"
OnItemDataBound="dgTollData_ItemDataBound" Font-Bold="true" Font-Size="12px">
<HeaderStyle CssClass="pageheading" Width="80%" HorizontalAlign="Center" BackColor="#DC143C"
Font-Bold="True" ForeColor="White" />
<AlternatingItemStyle CssClass="pageheading" BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<Columns>
<asp:BoundColumn DataField="PROJECT_NAME" HeaderText="Project Name"></asp:BoundColumn>
<asp:BoundColumn DataField="TOLL_REGIMENT_NAME" HeaderText="Toll Name" ItemStyle-Font-Size="12px"
ItemStyle-Width="15%"></asp:BoundColumn>
<asp:BoundColumn DataField="DATE" HeaderText="Date" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="8%" DataFormatString="{0:dd-MM-yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="TOTAL_TRAFFIC" HeaderText="Total Traffic" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="TIME" HeaderText="Between Time" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="15%"></asp:BoundColumn>
<asp:BoundColumn DataField="TOTAL_EXEMPTED" HeaderText="Total Exempted" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="TOTAL_NON_EXEMPTED" HeaderText="Total Non-Exempted" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="LMV" HeaderText="LMV (Car,Jeep)" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="LCV" HeaderText="LCV (Mini Bus/Tempo)" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="HVM" HeaderText="Bus/Truck" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="HCM" HeaderText="3 Axle Vehicle" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
<asp:BoundColumn DataField="MULTIAXEL" HeaderText="Oversie Vehicles" ItemStyle-HorizontalAlign="Center">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
<asp:Timer ID="tTimer" runat="server" OnTick="tTimer_Tick" Interval="10500" Enabled="true">
</asp:Timer>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="upProgress" runat="server" DisplayAfter="0" AssociatedUpdatePanelID="upsReport"
DynamicLayout="false">
<ProgressTemplate>
<div id="dProcessing" class="Box-Half">
</div>
</ProgressTemplate>
</asp:UpdateProgress>
Code behind:
----------
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GM.SetProjectData(this.ddlProjectName, 0);
this.ddlProjectName.Items.Insert(1, new ListItem("All", "-1"));
this.GetProjectTollData();
this.tbStartDate.Attributes.Add("readOnly", "readOnly");
}
}
protected void ddlProjectName_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (ddlProjectName.SelectedIndex > 0)
{
upsReport.Update();
this.ddlTollName.Items.Clear();
this.tbStartDate.Text = string.Empty;
GM.SetTollData(this.ddlTollName, Convert.ToInt32(this.ddlProjectName.SelectedValue));
if (ddlTollName.Items.Count > 0)
{
ddlTollName.Items.Insert(1, new ListItem("All", "-1"));
}
//zthis.GetProjectTollData();
}
}
catch (Exception ex)
{
throw ex;
}
}
protected void ddlTollName_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (ddlTollName.SelectedIndex > 0)
{
this.tbStartDate.Text = string.Empty;
this.GetProjectTollData();
}
}
catch (Exception ex)
{
throw ex;
}
}