onclick在数据绑定中不起作用 [英] onclick is not working in databound

查看:165
本文介绍了onclick在数据绑定中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:DataGrid id="dgEdit" runat="server" GridLines="None" Width="100%" AutoGenerateColumns="False" OnItemDataBound="dgEdit_ItemDataBound">
 <asp:TemplateColumn HeaderText="Project #">
                        <ItemTemplate>
<select class="tx" name="ddlProject" id="ddlProject"  runat="server" style="width: 72px"  ></select>
</ItemTemplate>
</asp:TemplateColumn>

</asp:DataGrid>

 protected void dgEdit_ItemDataBound(object sender, DataGridItemEventArgs e)
    {

        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            indexid = indexid + 1;
            HtmlImage setDate = (HtmlImage)e.Item.FindControl("setDate");
    setDate.Attributes.Add("onclick", "showCalendarControl(document.getElementById('dgEdit__ctl" + indexid + "_txtdate'));");
}







以上代码在.net 2环境下运行正常。我现在更新项目的.net版本onclick事件现在没有激活。没有错误...不知道修复plz帮助我




The above code is working fine in .net 2 environment . i update the .net version of the project now the onclick event is not firing now. no error ... no idea to fix plz help me

推荐答案

根据我的经验,您的控件的客户端ID从2.0更改为4.0。似乎document.getElementById(''dgEdit__ctl+ indexid +_txtdate'')不起作用,因为文本框的客户端ID已更改。



请查看页面的来源并确认我。在这种情况下,我可以为您提供解决方案。
As per my experience the client id of your control is changed from 2.0 to 4.0. It seems like document.getElementById(''dgEdit__ctl" + indexid + "_txtdate'') is not working as client id for text box is changed.

Please look into view source of the page and confirm me. I can provide you the solution in that case.


这篇关于onclick在数据绑定中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆