C#无法在Datalist EditItemTemplate中获取DropDownList或Textbox Value(文本)

时间:2015-05-22 13:31:11

标签: asp.net textbox edititemtemplate

我无法在Datalist EditItemTemplate中获取DropDownlist值,因为它变为null。我尝试Textbox值控制但它们再次变为null。我通过FinControl方法找到控制但它的null。我不使用scriptmanager并使用usercontrol你可以帮我解决这个问题吗?感谢..

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 个答案:

没有答案