日期:2014-05-17  浏览次数:20388 次

关于Datagrid里的EditItemTemplate
一个Datagrid

前台代码:

<Columns>
<asp:BoundColumn   DataField="Id">
</asp:BoundColumn>

<asp:TemplateColumn HeaderText="类型">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "TypeName").ToString()%>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="Dropdownlist2"   AutoPostBack="true"  OnSelectedIndexChanged="Dropdownlist2_SelectedIndexChanged" ></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>


<asp:BoundColumn DataField="ABC">
</asp:BoundColumn>

<asp:EditCommandColumn CancelText="取消" EditText="编辑" UpdateText="更新"></asp:EditCommandColumn>

</Columns>





后台代码:


protected void Dropdownlist2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList)sender;
            TextBox strABC=????(我想找到DataField="ABC"这一列的TextBox)

        }





我想找到DataField="ABC"这一列的TextBox,请问这个问题应该如何解决?


------解决方案--------------------
改为自定义模版。

http://www.cnblogs.com/insus/articles/1944295.html
http://www.cnblogs.com/insus/archive/2012/09/22/2698003.html
http://www.cnblogs.com/insus/archive/2012/10/24/2737483.html
http://www.cnblogs.com/insus/archive/2012/09/22/2697862.html