这样的值如何获得???
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[e.Row.Cells.Count - 1].Text = "<input type='checkbox' runat='server' id='checkbox' value='"+GridView1.DataKeys[e.Row.RowIndex].Value+"'>";HtmlInputCheckBox checkbox = (HtmlInputCheckBox)e.Row.Cells[e.Row.Cells.Count - 1].FindControl("checkbox");}
}
我现在用这个方法实现多选.怎么获得不了它的值呢......
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[e.Row.Cells.Count - 1].Text = "<input type='checkbox' runat='server' id='checkbox' value='"+GridView1.DataKeys[e.Row.RowIndex].Value+"'>";HtmlInputCheckBox checkbox = (HtmlInputCheckBox)e.Row.Cells[e.Row.Cells.Count - 1].FindControl("checkbox");}
}
我现在用这个方法实现多选.怎么获得不了它的值呢......
解决方案 »
- 母版页问题..高手们帮帮忙..
- 求解:为何使用wb.execwb(6, 6);打印时经常只能打印出第一页!?
- asp.net网站中如何高效的使用绝对路径
- 怎样将lable.text的值转换成int型
- asp.net 分页问题
- **********如何动态添加TabContainer和在TabContainer里动态添加TabPanel**************
- 请问管理员:怎么样才可以做斑竹?
- 在线请教一个用脚本代码判断DataGrid中是否有选中的项目?
- 一个项目中在多个目录下虚拟目录URL的问题
- 关于VS2010+SVN多人协同开发的问题
- 求:BS系统开发核心技术资料大全!!!!!!!!!!!!!!
- 菜鸟问题
用这样动态生成一个控件:
using (HtmlGenericControl genC = new HtmlGenericControl("DIV"))
{
genC.ID = "wscDivTipsSystem";
genC.Style.Add("font-family", "Times New Roman,Arial, Helvetica, sans-serif");
genC.Style.Add("position", "absolute");
genC.Style.Add("border", "solid 1px black"); genC.InnerHtml = "你的HTML"; try { this.Form.Controls.Add(genC); }
catch { this.Page.Controls.Add(genC); }
}
的没有看清代码吧................里面有加.我想我没写清楚吧.........我也知道模版列很容易.我的datacolum全是动态的.你选择可以是一个列也可以是十个列二十个列这个列是不确定的.你用模版列你如何加到最后一个.因为 AutoGenerateColumns是true不是false.
所以出来的gridview.column.count是0.我的gridview绑定的是个datatable.
这个datatable也是动态生成的正如上面所说可以有不限制的1-20列.
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[e.Row.Cells.Count - 1].Text = "<input type='checkbox' runat='server' id='chkItem' value='" + GridView1.DataKeys[e.Row.RowIndex].Value + "'>";
e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "document.getElementById('HdnSelectedValues').value='';");
}
用的客户端代码解决的。
function kk()
{
for (var i=0;i<document.form1.elements.length;i++)
{
var e = document.form1.elements[i];
if ( (e.type=='checkbox') )
{
if(e.checked)
{
document.getElementById('HdnSelectedValues').value+=document.form1.elements[i].value+",";
}
}
}
}
然后给个按纽触发这个客户端事件就好.感谢Knight94.虽然你的代码对我的帮助不大.但很感谢你的帮助.
肯定是错误的,你在模板列就可以了