Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am doing location-city-state-country page.in location page i have 3 dropdowns and based on the values selected in dropdown list data to the gridview is binded.for that i use follwing method
C#
public void fillgrid()
       {
           Int32 country_id = Convert.ToInt32(ddcountry.SelectedValue == "" ? "0" : ddcountry.SelectedValue);
           Int32 state_id = Convert.ToInt32(ddstate.SelectedValue == "" ? "0" : ddstate.SelectedValue);
           Int32 city_id = Convert.ToInt32(ddcity.SelectedValue == "" ? "0" : ddcity.SelectedValue);
           Common obj = new Common();
           DataSet ds = obj.BindingGridview(country_id, state_id, city_id);
           gvlocation.DataSource = ds;
           gvlocation.DataBind();
       }

i have also a search button and i bind the gridview based on value in search textbox.for that i use follwing code
C#
public void BindGV(string locationname)
     {

         Common obj = new Common();
         locationname = "%" + locationname + "%";
         DataSet ds = obj.GetAllLocation(locationname);
         gvlocation.DataSource = ds.Tables[0];
         gvlocation.DataBind();

     }

The problem is that i can bind only one method to gridview during edit/update/delete.normally i select first method.but when i press edit button of gridview which shows search Result, it causes problem .
protected void gvlocation_RowEditing(object sender, GridViewEditEventArgs e)
{
gvlocation.EditIndex = e.NewEditIndex;
fillgrid();
}
Posted
Updated 11-Jun-12 2:33am
v3

Correct this line:
C#
gvlocation.DataSource = ds;

to
C#
gvlocation.DataSource = ds.Tables[0];
 
Share this answer
 
Comments
subin joseph 11-Jun-12 8:38am    
i dont thik so.ie if my search result contain 3 values and i click edit button then gridview Rowediting() calls default bind method which returns values based on selected values in dropdown
you sd take a static flag and set on search then when u are in edit mode fill according to flag remember to unset after dropdown select
 
Share this answer
 
Comments
subin joseph 11-Jun-12 23:04pm    
thanks.this will work.

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