C# Can't get DropDownList or Textbox Value (text) in Datalist EditItemTemplate

141 Views Asked by At

I can't get DropDownlist value in Datalist EditItemTemplate cause it turns null. I try Textbox value control but they turn null again. I find control by FinControl method but its null. I don't use scriptmanager and using usercontrol could you help me about that pls? Thanks..

case "update":
                {
                    //foreach (DataListItem item in dlsepetim.Items)
                    //{
                    //    DropDownList tb = (DropDownList)item.FindControl("editdrop");
                    //    Response.Write(Convert.ToString(tb.SelectedIndex));
                    //}  

                    //int id = Convert.ToInt32(e.CommandArgument.ToString());
                    List<DL.Lib.Cart> sepetimu = CartManipulations.GetCart(Session["sepetim"]);
                    DL.Lib.Cart c = new Lib.Cart();
                    c = sepetimu.ElementAt(e.Item.ItemIndex);
                   //bool StokDurumu = bool.Parse(DataBinder.Eval(dr, "InStock").ToString());

                    //Response.Write(Convert.ToString(c.Quantity).ToString() + " " + c.ProductId + " " + c.ProductName);
                    DropDownList txt = (DropDownList)dlsepetim.Items[0].FindControl("editdrop");

                    int newQuantity = (e.Item.FindControl("editdrop") as DropDownList).SelectedIndex;

                    c.Quantity = newQuantity;
                    Session["sepetim"] = sepetimu;
                    dlsepetim.DataSource = CartManipulations.GetCart(Session["sepetim"]);
                    dlsepetim.EditItemIndex = -1;
                    dlsepetim.DataBind();
                }break;
0

There are 0 best solutions below