Thanks again ravi...it worked...but if i implement the same to another dropdownlist in the sam opage...it does not show any gridview...just blank..why?
Check if the dropdown has autopostback set to true. Check if you bind to gridview( GridView1.DataBind()).. Check if the query returns any rows which you are trying to bind to gridview
If you still face the problem, paste the code for the dopdown_selectedIndexChanged event
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataAdapter adp1 = new SqlDataAdapter("SELECT Customer_Detail.CustomerName_vc, UnitTypeCapacity_Detail.TankCapacity_vc, Unit_Detail.UnitSAPNo_vc, Unit_Detail.UnitName_vc, Unit_Detail.UnitLocation_vc, Unit_Detail.UnitDescription_vc, Unit_Detail.UnitStatus_b FROM Unit_Detail INNER JOIN Customer_Detail ON Unit_Detail.UnitCustomerID_i = Customer_Detail.CustomerID_i INNER JOIN UnitTypeCapacity_Detail ON Unit_Detail.UnitTypeCapacity_i = UnitTypeCapacity_Detail.TankTypeID_i where UnitName_vc = '" + DropDownList2.SelectedValue + "'", con);
DataSet ds = new DataSet();
adp1.Fill(ds, "Unit");
GridView1.DataSourceID = String.Empty;
GridView1.DataSource = ds.Tables["Unit"];
GridView1.DataBind();
}
I chekced autopost back set to true.gridview.dataBind() is defined.It works fine if i select the value for textbox also..but why this 2nd dropdownlist doesnot work..same thing i did.Query is also same but accessing unitName ..thats it.
Ravi Kumar K...
Member
727 Points
155 Posts
Re: Conversion Error...why?
May 18, 2012 05:37 AM|LINK
GridView1.DataSource = ds;
GridView1.DataSourceID = String.Empty;
I mean add the line
GridView1.DataSourceID=String.Empty; after
GridView1.DataSource = dt.Tables["Customer"];
//add it here
GridView1.DataBind();
Refer
http://forums.asp.net/t/1098475.aspx/1
britarun
Member
157 Points
32 Posts
Re: Conversion Error...why?
May 18, 2012 07:07 AM|LINK
HI,
Change the dropdown line to below format
int i= int.parse(DropDownlist1.SelectedValue.ToString());
keerthana4ha...
Member
6 Points
39 Posts
Re: Conversion Error...why?
May 18, 2012 07:08 AM|LINK
Thanks again ravi...it worked...but if i implement the same to another dropdownlist in the sam opage...it does not show any gridview...just blank..why?
Ravi Kumar K...
Member
727 Points
155 Posts
Re: Conversion Error...why?
May 18, 2012 07:11 AM|LINK
Check if the dropdown has autopostback set to true. Check if you bind to gridview( GridView1.DataBind()).. Check if the query returns any rows which you are trying to bind to gridview
If you still face the problem, paste the code for the dopdown_selectedIndexChanged event
keerthana4ha...
Member
6 Points
39 Posts
Re: Conversion Error...why?
May 18, 2012 08:58 AM|LINK
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { SqlDataAdapter adp1 = new SqlDataAdapter("SELECT Customer_Detail.CustomerName_vc, UnitTypeCapacity_Detail.TankCapacity_vc, Unit_Detail.UnitSAPNo_vc, Unit_Detail.UnitName_vc, Unit_Detail.UnitLocation_vc, Unit_Detail.UnitDescription_vc, Unit_Detail.UnitStatus_b FROM Unit_Detail INNER JOIN Customer_Detail ON Unit_Detail.UnitCustomerID_i = Customer_Detail.CustomerID_i INNER JOIN UnitTypeCapacity_Detail ON Unit_Detail.UnitTypeCapacity_i = UnitTypeCapacity_Detail.TankTypeID_i where UnitName_vc = '" + DropDownList2.SelectedValue + "'", con); DataSet ds = new DataSet(); adp1.Fill(ds, "Unit"); GridView1.DataSourceID = String.Empty; GridView1.DataSource = ds.Tables["Unit"]; GridView1.DataBind(); } I chekced autopost back set to true.gridview.dataBind() is defined.It works fine if i select the value for textbox also..but why this 2nd dropdownlist doesnot work..same thing i did.Query is also same but accessing unitName ..thats it.Ravi Kumar K...
Member
727 Points
155 Posts
Re: Conversion Error...why?
May 18, 2012 09:42 AM|LINK
It looks fine, place a breakpoint inside the method and check if it is being hit, If yes, then run the query adapter is holding in sql server .