In my data base i have made a table with columns
ProductId int Unchecked
[Sports Name] nvarchar(50) Checked
Category nvarchar(50) Checked
Brand nvarchar(50) Checked
Image text Checked
MRP varchar(50) Checked
[Our Price] varchar(50) Checked
[You Save] varchar(50) Checked
[Shipping Charges] varchar(50) Checked
[Expected Delivery] varchar(50) Checked
and on the front hand i have create many linkbuttons such as badminton, tennis , table tennis etc.. and a drop downlist to choose the equipment wanted such as racket and shuttle for badminton, bat and ball for the cricket and so on after that a dropdownlist to choose its brand.
Now I want them to display the products as choosen by customer on the click and selection event only in one page not by creating page for each category Some what like this
(the coding is not exact, it is just sample that what i want)
if(badminton.click==true)
{
cmd.text= seclect * from products where [Sports Name == Badminton] And Category==setectedcategory and so on
}
else if(tennis.click==true
{
}
...........so on
or only in one statement just like
cmd.text= select * from products where [Sports Name]==LinkButton.click And all like this
Now please help me if u understand what i want.
There are some problems in your database, I have to point to:
Don’t use spaces in the columns’ names, such as
[Our Price],[Expected Delivery]. You can, but it is recommended not to do this. Your identifiers should comply to default rules for regular identifiers.For monetary or currency values, use
MONEY, SMALLMONEY1 it has many benifits, or evenDECIMALin some cases. NotNVARCHARthe way you did in yourProductstable.Use Date and Time data types instead of
NVARCHARlike in[Expected Delivery]. And the most important one:Your database isn’t normalized this way. You should create a separate tables for
Cateogries,SportsandBrands.For instance:
How Can I insert into the tables this way?
Later, when inserting into the
Productstable, in the insert from, you should display the list of sports, categories and brands asDropDownLists. But, in this drop down list, you only display the name of the entity. You only display theCategoryNamein the Categories dropdown,BrandNamein the Brands dropdown and so on. And you can do this using the following two properties of the drop down list:DataValueFieldto theId.DataTextFieldto theName.Something like:
Then you should insert only the selected id from the drop down list, and your
INSERTstatement would look something like:But How can I Select and Search?
The same in the Search form, you should display these entities as drop down list then search for the products with the id selected by the drop down list:
The same with your current problem, you can dynamically created link buttons from these entities, the categories list and sports list as well as other entities. This can be done using the
GridViewcontrol, then create a data source and bind it to this grid view. With an<ItemTemplate>as<asp:LinkButton>and bind it to the column name selected by your query. If you googled for this, you will find a lot of threads explaining how you can do this. For example :Hope this is what are you looking for.
1:In some cases, may be you shouldn’t use it.
2:In the
SportsEquipments, I used theIdas a primary key, this way you any equipment can be referenced by many sports. If you want to make the equipment unique for each sports make a composite key(SportId, EquipmentId)instead.