Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 3 dropdownlist and 3 tables in database


I need whene I select values in dropdown it comes only with the row which related to select value and but it in gridview????
Posted
Comments
Suman Zalodiya 26-Dec-11 2:04am    
I can't understand your question clearly. Please can you clarify it little.

use the dropdown's SelectedIndexChanged event to load the table of interest in a DataTable, then bind that to your DataGrid.

:)
 
Share this answer
 
Comments
Sarah Mohammed77 25-Dec-11 23:15pm    
how can I write that coding could U give me simple example ???
protected void ddlUsers_SelectedIndexChanged(object sender, EventArgs e)
{
string strQuery;
string userName = ddlUsers.SelectedItem.Text;
if(userName=="All")
strQuery = "SELECT .....";
else
strQuery = "SELECT .....Where SCEUD.UserId='" + userName + "'";
DataSet dsHistory = ExecStatements(strQuery);
//here I am using the list box ... ur code goes here
lstHistory.DataSource = dsHistory;
lstHistory.DataTextField = "url";
lstHistory.DataBind();
}

protected DataSet ExecStatements(string sqlCmd)
{
SqlConnection sqlConn = new SqlConnection(strConnection);
SqlCommand sqlComm = new SqlCommand(sqlCmd, sqlConn);
SqlDataAdapter sqa = new SqlDataAdapter(sqlComm);
DataSet ds = new DataSet();
sqlConn.Open();
sqa.Fill(ds);
sqlConn.Close();
return ds;
}
 
Share this answer
 

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