作者whileloop (回圈)
看板C_Sharp
标题Re: [问题] GridView的样板
时间Sun Apr 19 17:55:20 2009
感谢前面推文的网友,可能我表达不够清楚
所以即使没有错误讯息,但结果并非我所想要的。抱歉,重来.. ^^|||
在GridView有一栏设定为样板,当按下编辑後会看到这个样板有LinkButton、TextBox
这个LinkButton当OnClick後会设定一个值给TextBox
如果撇开是在GridView的样板来说,只是单纯LinkButton的Onclick後设定值给TextBox
protected void LinkButton1_Click(object sender, EventArgs e)
{
TextBox1.text="TEST!!";
}
这是当然没有问题..
但是若是前面所述要在编辑样版里,这样设定就会有问题...
是否能不吝说明该如何解决? 谢谢!
※ 引述《whileloop (回圈)》之铭言:
: A.aspx:
: <asp:GridView ID="GridView1" runat="server" .....
: OnRowDataBound="GridView1_RowDataBound">
: A.aspx.cs:
: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
: {
: if (e.Row.RowType != DataControlRowType.DataRow)
: return;
: ((TextBox)e.Row.FindControl("TextBox_CompleteTime")).Text = "TEST!!";
: }
: 问题依旧.. XD
: 既然样板里的Button,不用FindControl这个Button就可以产生OnClick的事件
: 为什麽同一个样板里的TextBox却要用FindControl..
: 既然一定要用FindControl,R大的方式我仍然有问题,请问我可能是出现了哪些问题?
: 谢谢! ^^"
: ※ 引述《rayhill (....)》之铭言:
: : protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
: : {
: : if (e.Row.RowType != DataControlRowType.DataRow)
: : return;
: : ((TextBox)e.Row.FindControl("TextBox1")).Text = "Hello!!";
: : }
: : 结果是正确的啊..
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 125.225.161.244