日期:2014-05-18  浏览次数:20362 次

问两个关于DataList的问题
因为刚学DataList,用下来有2个问题
protected   void   DataList1_EditCommand(object   source,   DataListCommandEventArgs   e)
                {
                        this.DataList1.EditItemIndex   =   e.Item.ItemIndex;
                        this.DataBindToDataList();
                        ProvinceOper   oper1   =   new   ProvinceOper();
                        ((DropDownList)e.Item.FindControl( "DropDownList1 ")).DataSource   =   oper1.GetAllInfo().Tables[ "province "];
                        //((DropDownList)e.Item.FindControl( "DropDownList1 ")).DataValueField   =   "proID ";
                        //((DropDownList)e.Item.FindControl( "DropDownList1 ")).DataTextField   =   "proName ";
                        //((DropDownList)e.Item.FindControl( "DropDownList1 ")).DataBind();

                }
为什么取不到DropDownList1,取的的是null,而在
<EditItemTemplate>
                                <asp:Label   ID= "Label1 "   runat= "server "   Text= "Label "> </asp:Label>
                                <br   />
                                <asp:DropDownList   ID= "DropDownList1 "   runat= "server ">
                                </asp:DropDownList> <br   />
                                <asp:DropDownList   ID= "DropDownList2 "   runat= "server ">
                                </asp:DropDownList>
                                <asp:Button   ID= "Button1 "   runat= "server "   Text= "保存 "   />
                                <asp:Button   ID= "Button2 "   runat= "server "   Text= "返回 "   />
                        </EditItemTemplate>
还有就是 <%#   DataBinder.Eval(Container.DataItem,   "gender ")   ==   "True "   ?   "男 "   :   "女 "%> 为什么显示出来的全是女?

------解决方案--------------------
如果想得到EditItemTemplate的内容,应该是在UpdateCommand事件和DeleteCommand事件中得到