.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Dropdownlist selected changed event

Posted By: Rama Krishna     Posted Date: October 26, 2010    Points:2   Category :C#
my dropdownlist is populated with dept names,

whenever i selected one dept name from dropdownlist,

my requirement is remaining deptnames exceept selected one are display in agridview




SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RKConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("select deptno,dname from dept",con);
con.Open();
SqlDataReader dr=cmd.ExecuteReader();
DropDownList1.DataSource = dr;
DropDownList1.DataTextField = "deptno";
DropDownList1.DataTextField = "dname";
DropDownList1.DataBind();
con.Close();
under selected change event which code will be write?

any help

Responses
Author: Santosh             
Posted Date: October 27, 2010     Points: 5   

Hi
Try Below Code
Here cmbShift is the dropdownlist and DgvDisplay si the datagridview name

DgvDisplay.Rows.Add(cmbShift.Items.Count);
for (int i = 0; i <= cmbShift.Items.Count - 1; i++) {
if (cmbShift.Items.Item(i).ToString == cmbShift.Text) {
} else {
DgvDisplay.Rows(i).Cells(3).Value = cmbShift.Items.Item(i).ToString;
}

}


Regards
Santosh



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend