Dropdownlist select only first value
-
here is my code whenever i want to change the value of my dropdownlist i select only first value it can't change to any other value. plz chk and reply
private void bounddropdownlist()
{
string query = "select CouponName,CouponTypeID from CouponType";
DAL Helper = new DAL();
Helper.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
ds = new DataSet();
ds = Helper.ExecuteDataSet(CommandType.Text, query, null);
ddlCType.DataValueField = "CouponTypeID";
ddlCType.DataTextField = "CouponName";
ddlCType.DataSource = ds;
ddlCType.DataBind();
} -
here is my code whenever i want to change the value of my dropdownlist i select only first value it can't change to any other value. plz chk and reply
private void bounddropdownlist()
{
string query = "select CouponName,CouponTypeID from CouponType";
DAL Helper = new DAL();
Helper.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
ds = new DataSet();
ds = Helper.ExecuteDataSet(CommandType.Text, query, null);
ddlCType.DataValueField = "CouponTypeID";
ddlCType.DataTextField = "CouponName";
ddlCType.DataSource = ds;
ddlCType.DataBind();
}Well, again, your code really sucks. You need to abandon this project, and work on something more simple while you are just learning and cannot write commercial quality code. You seem to not know anything about ASP.NET and how it works yet.
haleemasher wrote:
ddlCType.DataBind();
Every time you do this, the selected index is reset. I assume you call it in page load, and it therefore runs prior to your event, which is the problem.
haleemasher wrote:
string query = "select CouponName,CouponTypeID from CouponType"; DAL Helper = new DAL(); Helper.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString(); ds = new DataSet(); ds = Helper.ExecuteDataSet(CommandType.Text, query, null);
This is an absolute joke.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Well, again, your code really sucks. You need to abandon this project, and work on something more simple while you are just learning and cannot write commercial quality code. You seem to not know anything about ASP.NET and how it works yet.
haleemasher wrote:
ddlCType.DataBind();
Every time you do this, the selected index is reset. I assume you call it in page load, and it therefore runs prior to your event, which is the problem.
haleemasher wrote:
string query = "select CouponName,CouponTypeID from CouponType"; DAL Helper = new DAL(); Helper.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString(); ds = new DataSet(); ds = Helper.ExecuteDataSet(CommandType.Text, query, null);
This is an absolute joke.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
u mean i will write
ddlCType.DataBind();
in page load or i write all my code in pageload????
-
u mean i will write
ddlCType.DataBind();
in page load or i write all my code in pageload????
I assume this method is being called by pageload now ? What is calling it ? I am saying if you do this in page load, or any time prior to trying to access the selection, it will reset the selection. In fact, you should use IsPostback blocks to only load the data the first time, after that, it is in viewstate
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Well, again, your code really sucks. You need to abandon this project, and work on something more simple while you are just learning and cannot write commercial quality code. You seem to not know anything about ASP.NET and how it works yet.
haleemasher wrote:
ddlCType.DataBind();
Every time you do this, the selected index is reset. I assume you call it in page load, and it therefore runs prior to your event, which is the problem.
haleemasher wrote:
string query = "select CouponName,CouponTypeID from CouponType"; DAL Helper = new DAL(); Helper.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString(); ds = new DataSet(); ds = Helper.ExecuteDataSet(CommandType.Text, query, null);
This is an absolute joke.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
I think
DataSet
andDataTable
are the most misused classes in .NET framework. :)Navaneeth How to use google | Ask smart questions
-
I think
DataSet
andDataTable
are the most misused classes in .NET framework. :)Navaneeth How to use google | Ask smart questions
Well, for a class called DAL to require a connection string AND SQL, just beggars belief. The sad thing is, someone somewhere is paying for this code, and I am certain he will ignore what I said, and deliver a project that is poorly written, unmaintainable, and totally insecure. You have to wonder who is basing their inventory systems, staff management and other vital functions to this sort of third rate beginner code, and, worse, if the bad job being done by these people, will end up reflecting on how dumb managers view you and I, people who have done the work to learn how to write professional code, before presuming to charge money for our efforts.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Well, for a class called DAL to require a connection string AND SQL, just beggars belief. The sad thing is, someone somewhere is paying for this code, and I am certain he will ignore what I said, and deliver a project that is poorly written, unmaintainable, and totally insecure. You have to wonder who is basing their inventory systems, staff management and other vital functions to this sort of third rate beginner code, and, worse, if the bad job being done by these people, will end up reflecting on how dumb managers view you and I, people who have done the work to learn how to write professional code, before presuming to charge money for our efforts.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Christian Graus wrote:
and deliver a project that is poorly written, unmaintainable, and totally insecure.
Whatever Christian is pointed out is right but If proper code review is there it won't happen. right?
Arun Jacob http://codepronet.blogspot.com/