后台:
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>