Hi, I am new to the web programming area and looking for some help. I have a situation where, like i said in my subject trying to base the list in the ddl2, to be based on the selection from ddl1. What do i all need to include to do this. As of now, I have two seperate SQL data sources, with the first one I have it just selecting from our database. For the second list, I have a second sql data source that does a selection of a different column from teh same database but in the where clause have a parameter that will equal the selection from teh first.. i.e. select project from database A and select class from database A where project = @ project. Then the control ID for the parameter is the first dropdownlist.. IT is only returning 1 possible selection in my ddl2, and doesnt update when selecting a different one from ddl1. I guess what am i missing, or what else do i need to include.?
![]() |
0 |
![]() |
See my post here: http://forums.asp.net/t/1176110.aspx
It has an example of what you're looking for.
Mathminded
mathminded at hotmail dot com
![]() |
0 |
![]() |
Hi
Here is an example.In the page load event
protected void Page_Load(object sender, EventArgs e)
{if (!this.IsPostBack)
{SqlDataAdapter sqlAdapter3 = new SqlDataAdapter("SELECT * FROM [tbl_Categories]", cn);
DataSet dset = new DataSet();
sqlAdapter3.Fill(dset, "dss");
DataRow dr3 = dset.Tables["dss"].NewRow();
dr3["CategoryID"] = "0";
dr3["Title"] = "------Categories------";
dset.Tables["dss"].Rows.InsertAt(dr3, 0);
ddlCategory.DataSource = dset.Tables["dss"].DefaultView;
ddlCategory.DataBind();String result = ddlCategory.SelectedValue;
SqlDataAdapter sqlAdapter4 = new SqlDataAdapter("SELECT * FROM [tbl_Products] WHERE [CategoryID] = '" + result + "'", cn);
DataSet dset1 = new DataSet();
sqlAdapter4.Fill(dset1, "dss1");
DataRow dr4 = dset1.Tables["dss1"].NewRow();
dr4["ProductID"] = "0";
dr4["Title"] = "------Product Code------";
dset1.Tables["dss1"].Rows.InsertAt(dr4, 0);
Products.DataSource = dset1.Tables["dss1"].DefaultView;
Products.DataBind();}
}
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
String result = ddlCategory.SelectedValue;
SqlDataAdapter sqlAdapter4 = new SqlDataAdapter("SELECT * FROM [tbl_Products] WHERE [CategoryID] = '"+result+"'", cn);
DataSet dset1 = new DataSet();
sqlAdapter4.Fill(dset1, "dss1");
Products.DataSource=dset1.Tables["dss1"].DefaultView;
Products.DataBind();
}Hope that helps
Thanks & Regards
Mark as Answer if it helps you. Thanks
BISVN JSC COMPANY
![]() |
0 |
![]() |
a4nsd:
Here is an example.In the page load eventHow is that different than my example?
Mathminded
mathminded at hotmail dot com
![]() |
0 |
![]() |
Ok... Thanks for your help, i had a stupid mistake and didnt have autopostback - to true... So that helps that problem.
But i do have one more issue. Im doing this within a gridview.. Its defaulting to 7 rows. Im looking around and cant find a setting to set this so its either drastically larger, or better yet, to set it to 1 and then.. Ideally on selection of dropdown, or probably on a button click (add row button) is there a way to add another row to the gridview
![]() |
0 |
![]() |
skooks:
Ok... Thanks for your help, i had a stupid mistake and didnt have autopostback - to true... So that helps that problem.
But i do have one more issue. Im doing this within a gridview.. Its defaulting to 7 rows. Im looking around and cant find a setting to set this so its either drastically larger, or better yet, to set it to 1 and then.. Ideally on selection of dropdown, or probably on a button click (add row button) is there a way to add another row to the gridview
Hi skooks,
From your description, I understand that you want to know how to add a row to the grid view,
generally speaking, a grid view was used for binding a SqlDataSource, and you can use the
Insert Command of the SqlDataSource to insert a row to the data source and therefore the
grid view would been added a new row.For more information about how to insert a new row to a grid view, please visit the following Web sites.
http://www.c-sharpcorner.com/UploadFile/Art%20Scott/GridViewInsertANewRow09012006165053PM/GridViewInsertANewRow.aspxHope this Information is helpful!
Xun
Regards,
Xun Ye.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that
helps you, and to click “Unmark as Answer” if a marked post
does not actually answer your question. This can be beneficial
to other community members reading the thread.
![]() |
0 |
![]() |
Which is defaulting to 7 rows, the gridview or the dropdownlist?
Peter Brunone
MS MVP, ASP.NET
Founder, EasyListBox.com
Do the impossible, and go home early.
![]() |
0 |
![]() |
Well the gridview is defaulting to 7 rows... Here is my dillema. I have info from a table i want to display in the gridview.. a product/op.system/release#/Old release#
I want the ones displayed to come from a the last release #.. So there will be a bunch of different products and op. systems... But they also want it to be editible by dropdown.. SO i essentially want to show everything that was submitted in teh last release, but then if they want to change something just click on the product and scroll the dropdown to what they want to edit...
![]() |
0 |
![]() |