后台:
private void Page_Load(object sender, System.EventArgs e)
{
//这里是给DataGrid绑定数据库
OleDbConnection con=DB.createcon();
OleDbDataAdapter oda=new OleDbDataAdapter();
oda.SelectCommand =new OleDbCommand ("select * from mp3",con);
DataSet ds=new DataSet();
oda.Fill(ds,"mp3");
this.DataGrid1 .DataSource =ds.Tables["mp3"].DefaultView;
this.DataGrid1.DataBind();
// 在此处放置用户代码以初始化页面
}private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//这里是给DataGird的行添加Click事件
if (e.Item .ItemType !=ListItemType.Header||e.Item .ItemType !=ListItemType.Footer )
{
e.Item .Attributes .Add ("onclick","checkone("+e.Item .Cells [0].Text +")");
}
}前台:
<script>
function checkone(s)
{
//把所点击的行的1项的值传给Text1
document.getElementById ("Text1").value=s
//问题在这里了,如果所点击行的值为"123.MP3"也就是有小数点的时候网页就会出错提示“缺少')'”如果所点击行的值为"123"也就是没有小数点的时候就没事;要如何解决?}
</script>
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 103; LEFT: 416px; POSITION: absolute; TOP: 24px"runat="server" Height="64px" Width="112px"></asp:DataGrid>
<asp:TextBox id="Text1" style="Z-INDEX: 102; LEFT: 432px; POSITION: absolute; TOP: 232px" runat="server"></asp:TextBox>
private void Page_Load(object sender, System.EventArgs e)
{
//这里是给DataGrid绑定数据库
OleDbConnection con=DB.createcon();
OleDbDataAdapter oda=new OleDbDataAdapter();
oda.SelectCommand =new OleDbCommand ("select * from mp3",con);
DataSet ds=new DataSet();
oda.Fill(ds,"mp3");
this.DataGrid1 .DataSource =ds.Tables["mp3"].DefaultView;
this.DataGrid1.DataBind();
// 在此处放置用户代码以初始化页面
}private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//这里是给DataGird的行添加Click事件
if (e.Item .ItemType !=ListItemType.Header||e.Item .ItemType !=ListItemType.Footer )
{
e.Item .Attributes .Add ("onclick","checkone("+e.Item .Cells [0].Text +")");
}
}前台:
<script>
function checkone(s)
{
//把所点击的行的1项的值传给Text1
document.getElementById ("Text1").value=s
//问题在这里了,如果所点击行的值为"123.MP3"也就是有小数点的时候网页就会出错提示“缺少')'”如果所点击行的值为"123"也就是没有小数点的时候就没事;要如何解决?}
</script>
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 103; LEFT: 416px; POSITION: absolute; TOP: 24px"runat="server" Height="64px" Width="112px"></asp:DataGrid>
<asp:TextBox id="Text1" style="Z-INDEX: 102; LEFT: 432px; POSITION: absolute; TOP: 232px" runat="server"></asp:TextBox>
解决方案 »
- AjaxPro与ASP.NET AJAX1.0冲突的问题 急~~ 在线等
- 正则表达式问题
- 关于 textbox and gridview 的
- 求一个导出excell的方法,以不要打印字符串,生成文件的伪excell。也不是把控件设置一下属性,吧html生成文件
- 菜鸟学.net 关于怎么控制VS里的界面
- CheckBoxList的问题
- 求生成缩略图代码﹐谢谢了
- 我是新手请较各位一个关于连接sql的问题
- jquery读取json数据失败
- 各位救命啊!为什么我的程序在有的机器上面可以运行,在有的机器上面就不可以,出现的错误如下
- 关于web.config中基于表单的验证的问题
- 这个世界太疯狂了,送分贴,问如何"查找",我要查找项目中这个类在哪些地方被使用过..明明有,怎么查不到..
e.Item .Attributes .Add ("onclick","checkone('"+e.Item .Cells [0].Text +"')");