在datalist控件中添加了一个textbox和一个button,button的方法是CommandBtn_Click,当点击button时,将textbox的值赋为空,这段语句怎么写
------解决方案--------------------------------------------------------
楼主用textBox的话一般是在编辑界面内
((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text="";
1楼里面的代码
------解决方案--------------------------------------------------------
- HTML code
<%@ Page Language="C#" AutoEventWireup="true" enableEventValidation="false" CodeFile="DataList.aspx.cs" Inherits="DataList" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title></head><body> <form id="form1" runat="server"> <div> <asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound"> <ItemTemplate> <asp:TextBox ID='txt' runat="server" Text='<%# Eval("学生姓名") %>'></asp:TextBox> <asp:Button ID="CommandBtn" runat="server" Text="Button" OnClick="CommandBtn_Click" /> </ItemTemplate> </asp:DataList></div> </form></body></html>
------解决方案--------------------------------------------------------
同2楼
或google 事件冒泡
或 http://www.cnblogs.com/huobazi/archive/2006/04/08/TwoDropDownListInDataGridAndBubbleEvent
------解决方案--------------------------------------------------------
1楼正解