Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friends/sirs

Iam working on dropdownlist,and Gridview. When i select one item from dropdown it must be displayed in GRIDVIEW. Everything is going fine in this.

BUT when i selected item from Dropdownlist Complete page is Refreshing.
Note : Page must be not refreshed, when item selected from dropdown.

please anybody can give me the code for that.

Thank u frnds.
Posted
Comments
Vipin_Arora 25-Apr-12 3:13am    
For partial Page Updation, UpdatePanel of AJAX

 
Share this answer
 
v2
Comments
Sandhya Lovely 25-Apr-12 2:15am    
how, please can u suggest me ? and give me code for that, am Beginner to development.
Anuj Banka 25-Apr-12 2:16am    
i have given you a link which will give you an idea..
Sandhya Lovely 25-Apr-12 2:27am    
I have tried this, but am unable to displa the selected items from dropdown.
and also gave postback to true
Anuj Banka 25-Apr-12 2:28am    
post your code.
Sandhya Lovely 25-Apr-12 2:30am    
<div><asp:ScriptManager ID="ScriptManager" runat="server">
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
Height="20px" Width="160px"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="0">--------- Select ---------
<asp:ListItem>Sort By Airline
<asp:ListItem>Sort By Date
<asp:ListItem>Display All
<asp:ListItem>Expires
<asp:ListItem>Active
 
Share this answer
 
C#
protected void DDcat_SelectedIndexChanged(object sender, EventArgs e)
{
	if (DDcat.Selectedindex != 0) {
		dt = new datatable();
		Gridview1.datasource = dt;
		Gridview1.databind();
	}
}
Yow will try this
 
Share this answer
 
Comments
Sandhya Lovely 25-Apr-12 2:59am    
can i used scriptmanager and update panel after using this code.
Vasim889 25-Apr-12 3:05am    
update panel and scriptmanager also used to clientside invisibled for page postback to server .so it's not a matter?whatever binding in gridview to using datatable to bind.
Sandhya Lovely 25-Apr-12 3:11am    
ok, from where to start and end update panel, I have dropdown and gridview.
<div>
      <asp:ScriptManager ID="ScriptManager" runat="server">
  </div>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
      <ContentTemplate>
          <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Height="20px"
              Width="160px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
              <asp:ListItem Value="0">--------- Select ---------
          <asp:ListItem>Sort By Airline
          <asp:ListItem>Sort By Date
          <asp:ListItem>Display All
          <asp:ListItem>Expires
          <asp:ListItem>
              Active
          </asp:DropDownList>
          </td> </tr> </table></td> </tr>
          <tr>
              <td height="300" align="center" valign="top">
                  <table align="center">
                      <tr>
                          <td>
                              <table class="style3" align="center" bgcolor="White">
                                  <tr>
                                      <td class="style7">
                                          Search
                                      </td>
                                      <td class="style5">
                                          <asp:TextBox ID="TxtSearch" runat="server" Width="600px" Style="text-align: left">
                                      </td>
                                      <td class="style8">
                                          <asp:Button ID="BtnSearch" runat="server" Text="Go" Width="30px" BackColor="#E2BA20"
                                              ForeColor="White" OnClick="BtnSearch_Click" />
                                      </td>
                                  </tr>
                              </table>
                              <table class="style1">
                                  <tr>
                                      <td class="style4">
                                      </td>
                                      <td>
                                          <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Users/PrintAllReport.aspx">Print
                                          Report
                                      </td>
                                  </tr>
                              </table>
                              <asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="3" ForeColor="Black"
                                  PageSize="15" CssClass="red" HorizontalAlign="Center" Width="1100px" BackColor="LightGoldenrodYellow"
                                  CellSpacing="2" BorderColor="Tan" BorderWidth="1px" OnPageIndexChanging="GridView1_PageIndexChanging"
                                  OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowDataBound="GridView1_RowDataBound"
                                  ShowFooter="True">
                                  <PagerSettings Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last"
                                      PageButtonCount="5" />
                                  <asp:CommandField ShowSelectButton="True" />
                                  <HeaderStyle BackColor="Tan" Font-Bold="True" />
                                  <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center"
                                      CssClass="gridViewPager" />
                                  <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                              </asp:GridView>
                              </ContentTemplate>
                              </asp:UpdatePanel>
 
Share this answer
 
v2
Comments
Sandhya Lovely 25-Apr-12 3:18am    
I did it same, But the dropdown and gridview are displaying double
Anuj Banka 25-Apr-12 3:21am    
Please check your code carefully.Or jusr send your code to nsnitin200@gmail.com.i will check that .. And do not use fake ID's everyone is muture enough here.
Sandhya Lovely 25-Apr-12 3:24am    
ok, i.ll send it
Sandhya Lovely 25-Apr-12 3:40am    
chk email
Anuj Banka 25-Apr-12 4:18am    
check you mail.And mark it as answer if it helps you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900