我的gridview中有两个模板列 一列是linkbutton 一列是celender日历.我的linkbutton 里面OnClick="lbnDailyCustomize_Click“ 。当程序执行到lbnDailyCustomize_Click里面的时候如何找到相同row的 摸板列的celender的日期的取值呢?
另外模板列里的(linkbutton)sender 的parentcontrol是cell,cell 的parent 是什么?clumn 还是row? 谢谢
另外模板列里的(linkbutton)sender 的parentcontrol是cell,cell 的parent 是什么?clumn 还是row? 谢谢
LinkButton theLinkButton = (LinkButton)sender;
DataControlFieldCell theCell = (DataControlFieldCell)theLinkButton.Parent;
GridViewRow theRow = (GridViewRow)theCell.Parent;
在theRow中用FindControl找你的日历控件
{
LinkButton lbtn = sender as LinkButton;
lbtn.ForeColor = System.Drawing.Color.Red;//找到当前的按钮 GridViewRow row = lbtn.Parent.Parent as GridViewRow;//找到当前行
Calendar cad = row.FindControl("Calendar1") as Calendar ;
cad.Visible = false;//可以访问当前行的日历控件了
int curIndex = row.RowIndex;//当前行号
//.....
}