Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Friend

I am using Visual Studio 2008 window application and sql server2005 express

i have use one combo box and in that i have used Data bound item
i want that if user select the item from combo box then data should view in the Data Grid view

For ex : Combo box contain User name like ram sham so on
if user select the name ram
so in data grid view it should show what ram has buy like product name(Text box) , discount type(Text box).
then in same data grid view i have put two text box so the user can put the discount manually and condition manually

One more thing there are two different table in sql and i want to join them and there is no relation between them but i want on the selection of the combo box it should view in data grid :(



and how can i adjust the data grid view column

Thanks in Advance
Posted
Updated 12-Nov-10 0:27am
v4

place combo box and add sum fields into it. from the combo box selected event u should assign a selected item name into session key then u place a data grid view in ur page. with that data grid property u have to select data source and make a connection string related to the grid.

from the connection string u select the where clause and pointed to session variable in which u assigned the value from combo box.. then save the settings and run the page it will work,,

if u agreed above the above answer press accept answer or put vote for this answer..

all the best..
 
Share this answer
 
v2
Hi Arti,
its very simple to bind the gridview based ont the value u have selected in the combobox.

In the SelectedIndexChangedEvent() of your combobox, write your SQL Query to bind the gridview.
For e.g.

 protected void ComboBox_SelectedIndexChanged(object o, xSelectedIndexChangedEventArgs e)
{
    int Value=Convert.ToInt32(ComboBox.SelectedValue);
    
    //  Now Pass this int Value to your SQL query to fetch the records of THAT Value, and bind your grid.
   // Grid.DataSource=ds.Tables[0];   
}


I hope it will help.
If any query, pls revert back to me.
Or you can contact me on lokesh.zende@xecomit.com
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900