473,378 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Getting values from Dropdownlist

1
I am new in .asp I am trying to use dropdownlist to display values from the database and be able to query the database based on displayed values in a dropdownlist.
the prob is when I select any value in the dropdownlist and click a button to query a database the value in the dropdownlist changes back to the first value in the dropdownlist.
Here is the code: for the dropdownlist

private void DropView_SelectedIndexChanged(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("server=ITMGR;database=CSSMoneyTR;us er id=sa;password=");
SqlDataAdapter adapP;

DataSet dsP;
SqlCommand commP=new SqlCommand("select * from RevSenderInformation where branch ='"+DropView.SelectedValue+"'",conn);
conn.Open();
adapP=new SqlDataAdapter();
dsP=new DataSet();
commP.ExecuteNonQuery();
adapP.SelectCommand=commP;
adapP.Fill(dsP,"DSender");
DataGTrans.DataSource=dsP.Tables["DSender"].DefaultView;
DataGTrans.DataBind();
conn.Close();


}
and here is the code for button

private void Button1_Click(object sender, System.EventArgs e)
{

SqlConnection conn = new SqlConnection("server=ITMGR;database=CSSMoneyTR;us er id=sa;password=");
SqlDataAdapter adapP;

DataSet dsP;
SqlCommand commP=new SqlCommand("select * from RevSenderInformation where branch ='"+DropView.SelectedValue.ToString()+"'",conn);
conn.Open();
adapP=new SqlDataAdapter();
dsP=new DataSet();
commP.ExecuteNonQuery();
adapP.SelectCommand=commP;
adapP.Fill(dsP,"DSender");
DataGTrans.DataSource=dsP.Tables["DSender"].DefaultView;
DataGTrans.DataBind();
conn.Close();
}


Please any help shall be much appreciated.I want the dropdownlist not to change values to the first one.It seems it only retains the first value.
Regards
Edward
Feb 27 '08 #1
0 1056

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tim Zych | last post by:
I'm having problems with a dropdownlist control. I fill the control with values in the page_load event. But when I click the button the dropdownlist control gets cleared out. How do I use a...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
0
by: Mike P | last post by:
How do you get access to the values you have entered under edit mode in a gridview? I only seem to be able to access the values prior to them being edited. protected void...
0
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an...
1
by: Roffers | last post by:
Okay I have a parent page, we'll call it parent.aspx and it holds the following two user controls <uc1:Box1 id="Box1" runat="server"></uc1:Box1<----THIS CONTAINS A DROP DOWN LIST <br>...
4
by: preeti13 | last post by:
Hi friends i have a probelm i am try to pass the value to the employeeid parameter but getting th error please help me how i can do this i am getting the error here is my code using System;...
2
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into...
2
by: mylog | last post by:
Hi I am having a problem of getting the value from the dynamically generated table and dropdownlist. What I am facing is, I have created a table in the aspx page and now I need to add values to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.