Click here to Skip to main content
15,893,594 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionBack Function. Pin
Saksida Bojan14-Sep-07 11:08
Saksida Bojan14-Sep-07 11:08 
AnswerRe: Back Function. Pin
Brent Lamborn14-Sep-07 11:59
Brent Lamborn14-Sep-07 11:59 
GeneralRe: Back Function. Pin
Saksida Bojan14-Sep-07 12:02
Saksida Bojan14-Sep-07 12:02 
GeneralRe: Back Function. Pin
Brent Lamborn14-Sep-07 16:11
Brent Lamborn14-Sep-07 16:11 
GeneralRe: Back Function. Pin
Saksida Bojan15-Sep-07 7:03
Saksida Bojan15-Sep-07 7:03 
AnswerRe: Back Function. Pin
John-ph14-Sep-07 21:17
John-ph14-Sep-07 21:17 
GeneralRe: Back Function. Pin
Saksida Bojan15-Sep-07 7:04
Saksida Bojan15-Sep-07 7:04 
QuestionIntegrating 2 Data Controls , one as the Control to the Other Pin
ctrlnick14-Sep-07 11:01
ctrlnick14-Sep-07 11:01 
Hello All,.

I am facing a Problem Here.
I Have been trying to do this since 2 days.

Note : I am working on ASP.NET with C# as code behind

Assume that I have a the Following Database Tables from Northwind DataBase

1) Products
2) category

The Category table Contains Category ID and categoryName

The Products Table Contains ProductName , categoryID
I have a GridView whose data source is the ProductTable
I have a DropDownList whose data Source is the Category Table
and the dropdownlist Should only display the Category Name

Based on the Selected Category Name from the drop down list, the products Table should display on the GridView control which I added on the aspx page earlier

But the twist here is

In order to get the ProductNames from the Products Table , I have to pass the CategoryID only to the method that has the SQL Query.. GetProductsBycategoryID()

But I am only displaying the Category Names on the Drop Down List

How can I Relate the Names to their corresponding IDs and then pass the category ID to the GetProductsbycategoryID() function..


Please let me know on this.


This is the code I am trying to work on...

It is very dissorganised as I am trying different things

If this sample works for me , I can include this functionality in my project,.

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;
using System.Collections;
using NorthwindTableAdapters;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
CategoriesTableAdapter categoryAdapter = new CategoriesTableAdapter();
// ddl_Category.DataSource = categoryAdapter.GetCategories();
//ddl_Category.DataTextField = "CategoryName";
//ddl_Category.DataValueField = "CategoryID";
//ddl_Category.DataBind();
GridView1.DataSource = productsAdapter.GetProducts();
GridView1.DataBind();
ddl_Category.Items.Insert(0,"PleaseSelectACategory");
ddl_Category.Items.Insert(1, "Some1");
ddl_Category.Items.Insert(2, "Some2");
ddl_Category.Items.Insert(3, "Som3");
ddl_Category.Items.Insert(0, "PleaseSelectACategory");
ddl_Category.SelectedIndex = 0;


}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}

protected void ddl_Category_SelectedIndexChanged(object sender, EventArgs e)
{
////ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
//////int catID = ddl_Category.SelectedIndex;
////string somesome = ddl_Category.SelectedValue.ToString();
////int catID2 = Int32.Parse(somesome);

////GridView1.DataSource = productsAdapter.GetProductsByCategoryID(catID2);
////GridView1.DataBind();


}
protected void ddl_Category_SelectedTextChanged(object sender, EventArgs e)
{


}
}



Thanks a lot,
Nikhil Pagidala

Happy Programming!

Regards,
Nikhil Pagidala

AnswerUsing 2 Data Controls to show related Data Pin
John-ph14-Sep-07 20:41
John-ph14-Sep-07 20:41 
Questionwhy to use datasource to gridview? Pin
ss.mmm14-Sep-07 10:28
ss.mmm14-Sep-07 10:28 
AnswerRe: why to use datasource to gridview? Pin
Saksida Bojan14-Sep-07 11:19
Saksida Bojan14-Sep-07 11:19 
AnswerRe: why to use datasource to gridview? Pin
John-ph14-Sep-07 21:02
John-ph14-Sep-07 21:02 
QuestionSession, Cache or Viewstate Pin
ss.mmm14-Sep-07 10:08
ss.mmm14-Sep-07 10:08 
AnswerRe: Session, Cache or Viewstate Pin
N a v a n e e t h14-Sep-07 21:26
N a v a n e e t h14-Sep-07 21:26 
AnswerRe: Session, Cache or Viewstate Pin
John-ph14-Sep-07 23:25
John-ph14-Sep-07 23:25 
QuestionSession timeout doesn't work when sessionState mode is SQL server Pin
vicky45714-Sep-07 9:36
vicky45714-Sep-07 9:36 
AnswerRe: Session timeout doesn't work when sessionState mode is SQL server Pin
N a v a n e e t h14-Sep-07 21:18
N a v a n e e t h14-Sep-07 21:18 
QuestionNameSpace Pin
seemamltn14-Sep-07 8:10
seemamltn14-Sep-07 8:10 
AnswerRe: NameSpace Pin
Saksida Bojan14-Sep-07 9:28
Saksida Bojan14-Sep-07 9:28 
QuestionHow to debugging DLLs solutions Pin
Caio Vitor14-Sep-07 7:45
Caio Vitor14-Sep-07 7:45 
AnswerRe: How to debugging DLLs solutions Pin
Saksida Bojan14-Sep-07 9:45
Saksida Bojan14-Sep-07 9:45 
GeneralRe: How to debugging DLLs solutions Pin
Saksida Bojan14-Sep-07 11:14
Saksida Bojan14-Sep-07 11:14 
AnswerRe: How to debugging DLLs solutions Pin
ctrlnick14-Sep-07 11:07
ctrlnick14-Sep-07 11:07 
QuestionNeural Network? Pin
tanj005614-Sep-07 7:42
tanj005614-Sep-07 7:42 
QuestionHow to pass the gridview datakey to filter a dataset, help pleas Pin
orsini14-Sep-07 7:27
orsini14-Sep-07 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.