0

Please tell me the code for how to display record in datagridview based on combobox selected item.
I have a table named table1 in sql server database.and columns are name,id,group,grade,year.when i seleted one name from my table then the remaining fields information(ie only that record)have to dispaly in datagridview by click on the 'Display' button.

2
Contributors
1
Reply
10
Views
2 Years
Discussion Span
Last Post by riyamanavalan@g
0
sqlcommand cmd =new sqlcommand;
cmd.commandtext="select id, group,grade,year where name='"+combobox_selected item+"'"
sqldataadapter da=new sqldataadapter;
da.selectcommand=cmd;
datatable dt=new datatable();
da.fill(dt);
gridview1.datasource=dt;
gridview1.databind();

Hope this will help you....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.