I am having one web application...

On which i have one combobox whose autopostback propert is set to true....
its showing d same result that i want...
the only problem is that the page gets refreshed automatically when i select a data from combobox....

How to overcome this problem pls help me out.....

6 Years
Discussion Span
Last Post by vishalrane

Check your page load event. Your combobox may be bound to some data source which is making your combobox get refreshed with new values every time page gets refreshed .

You can use IsPostBack = False
and bound the data on change event of Combo box instead of page load event.

I hope this helps.


No its not working

Here is code:

Default.aspx Design:
Contain dropdown box,textbox,button

Default.aspx Source code:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
            DataTextField="UserId" DataValueField="UserId" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MOVIETICKETBOOKING.MDFConnectionString %>"
            SelectCommand="SELECT * FROM [UserInfo]"></asp:SqlDataSource>
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
       protected void Button1_Click(object sender, EventArgs e)
TextBox1.Text = DropDownList1.Text;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.