Need source code for the following:

when you select a particular entry in the DropdownList,
the other details of that entry should come in the datagrid.
also there should be options for edit,update and delete the records
from the datagrid.
Code Behind: C#
Database: SqlServer 2000

Let me understand first you loaded your Dropdown with values from the database and you want to select one of them and all of its details must appear on a dataGrid?


Need source code for the following:

when you select a particular entry in the DropdownList,
the other details of that entry should come in the datagrid.
also there should be options for edit,update and delete the records
from the datagrid.
Code Behind: C#
Database: SqlServer 2000

Yes, I have loaded the DropdownList with values from the database. Now when I select one of them all of its details must appear on a dataGrid?Edit and cancel buttons are working fine, But i'm having some problem in deleting and updating the datagrid.

all you have to do is create a stored procedure to select the Details that you want displayed on your dataGrid and it should get the parameter that comes from the dropdownlist's selectedValue for example but i'm sorry for me i'm using da as my data access layer data access layer

private void dropdown_SelectedIndexChanged(object sender, System.EventArgs e)
{
 try
   {
         if(Page.IsPostBack==true)
    {
    da.Parameters.Clear();  
    int i= Convert.ToInt32(dropdown.SelectedItem.Value);  
    da.AddParameter("stored procedure parameter",i); 
     DataSet ds = da.ExecuteDataSet("Your store procedure");
                dataGrid1.DataSource = ds.Tables[0] ;
    dataGrid1.DataBind();

    }
}
    catch(System.Exception ex)
    {
     ex.Message;

    }
        }

Yes, I have loaded the DropdownList with values from the database. Now when I select one of them all of its details must appear on a dataGrid? Edit and cancel buttons are working fine, But i'm having some problem in deleting and updating the datagrid.

Hello,
Thanx Roxion, thanx for the help... i solved my problem which i had in updating and deleting the datagrid...

wanted to know the difference between Page.IsPostBack and Not page.IsPostBack.
what is the purpose of using these? where it is being used?
can you help me with a small example.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.