取GridView中文本框的值
我把文章在列表中按它们是否被加密码判断完显示哪个Panel了,然后就是在有密码的Panel中向TextBox输入密码,点击确认按钮,代码如下,问题是取不出来TextBox中的值,我的这两个Panel(有密码显示的和没密码显示的Panel)是直接放在GridView的ItemTemplate中的,Colunm0,我做了试验,Panel放在规律的列中,比如Colunm3中,我就用Cells[2]就能取出来,那我这种情况应该怎样处理呢????
protected void btnCommit_Click(object sender, EventArgs e)
{
Button bt1 = sender as Button;
if (() == "bb")
{
foreach (GridViewRow gr in GridView1.Rows)
{
TextBox tb = (TextBox)gr.Cells[0].FindControl("txtPass");
string pass = ();
string password = tb.Text.Trim();
Panel p1 = (Panel)gr.Cells[0].FindControl("pPassNone");
Panel p2 = (Panel)gr.Cells[0].FindControl("pPass");
if (password == pass)
{
p1.Visible = true;
p2.Visible = false;
}
}
}
}