报错提示的代码如下:
行 175: <asp:TemplateColumn HeaderText="删除">
行 176: <ItemTemplate>
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server" OnClientClick='<%# deleteit("DataBinder.Eval(Container.DataItem,"P_ID")") %>'>LinkButtonDel</asp:LinkButton>
行 178: </ItemTemplate>
行 179: </asp:TemplateColumn>
源文件:... ... 行177
请高手解决一下,如何才能使这个客户端事件正确执行.
8 个解决方案
#1
既然deleteit()是一个js函数,为何还要<%#符号加前面呢?
OnClientClick='deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID")%>")'
OnClientClick='deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID")%>")'
#2
<%# deleteit("DataBinder.Eval(Container.DataItem,"P_ID")") %>
看看你的引号嵌套
<%# deleteit(DataBinder.Eval(Container.DataItem,"P_ID")) %>
看看你的引号嵌套
<%# deleteit(DataBinder.Eval(Container.DataItem,"P_ID")) %>
#3
没看清
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server"
OnClientClick='javascript: deleteit("<%#DataBinder.Eval(Container.DataItem,"P_ID")") %> '> LinkButtonDel </asp:LinkButton>
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server"
OnClientClick='javascript: deleteit("<%#DataBinder.Eval(Container.DataItem,"P_ID")") %> '> LinkButtonDel </asp:LinkButton>
#4
OnClientClick='deleteit(" <%# DataBinder.Eval(Container.DataItem,"P_ID")%> ")'
#5
各位老大:
我按您们教的,使用了
<asp:LinkButton ID="LinkButtonDel" runat="server" OnClientClick='javascript:deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>")' >LinkButtonDel</asp:LinkButton>
</ItemTemplate>
但还问题.
我在调试时,看到上面的代码变成了,如下:
<a onclick="deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>");" id="ProGrid__ctl4_LinkButtonDel" href="javascript:__doPostBack('ProGrid$_ctl4$LinkButtonDel','')">LinkButtonDel</a>
请高手解决!
我按您们教的,使用了
<asp:LinkButton ID="LinkButtonDel" runat="server" OnClientClick='javascript:deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>")' >LinkButtonDel</asp:LinkButton>
</ItemTemplate>
但还问题.
我在调试时,看到上面的代码变成了,如下:
<a onclick="deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>");" id="ProGrid__ctl4_LinkButtonDel" href="javascript:__doPostBack('ProGrid$_ctl4$LinkButtonDel','')">LinkButtonDel</a>
请高手解决!
#6
在后台邦定事件中做
private void dgData_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
rpAddress = e.Item.FindControl("LinkButtonDel") as LinkButton;
LinkButton..Attributes.Add("onclick", "javascript:deleteit(" + e.Item.Cells[0].Text + ")");
}
}
在前台控键中加<asp:boundcolumn datafield="P_ID"></asp:boundcolumn>作为第一列
private void dgData_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
rpAddress = e.Item.FindControl("LinkButtonDel") as LinkButton;
LinkButton..Attributes.Add("onclick", "javascript:deleteit(" + e.Item.Cells[0].Text + ")");
}
}
在前台控键中加<asp:boundcolumn datafield="P_ID"></asp:boundcolumn>作为第一列
#7
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server"
OnClientClick=javascript: deleteit(' <%#DataBinder.Eval(Container.DataItem,"P_ID")') %> > LinkButtonDel </asp:LinkButton>
直接这样写试试,不太标准
最好在itemdatabind事件中写
OnClientClick=javascript: deleteit(' <%#DataBinder.Eval(Container.DataItem,"P_ID")') %> > LinkButtonDel </asp:LinkButton>
直接这样写试试,不太标准
最好在itemdatabind事件中写
#8
请问一下bayo:
rpAddress是怎么来的?
rpAddress是怎么来的?
#1
既然deleteit()是一个js函数,为何还要<%#符号加前面呢?
OnClientClick='deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID")%>")'
OnClientClick='deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID")%>")'
#2
<%# deleteit("DataBinder.Eval(Container.DataItem,"P_ID")") %>
看看你的引号嵌套
<%# deleteit(DataBinder.Eval(Container.DataItem,"P_ID")) %>
看看你的引号嵌套
<%# deleteit(DataBinder.Eval(Container.DataItem,"P_ID")) %>
#3
没看清
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server"
OnClientClick='javascript: deleteit("<%#DataBinder.Eval(Container.DataItem,"P_ID")") %> '> LinkButtonDel </asp:LinkButton>
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server"
OnClientClick='javascript: deleteit("<%#DataBinder.Eval(Container.DataItem,"P_ID")") %> '> LinkButtonDel </asp:LinkButton>
#4
OnClientClick='deleteit(" <%# DataBinder.Eval(Container.DataItem,"P_ID")%> ")'
#5
各位老大:
我按您们教的,使用了
<asp:LinkButton ID="LinkButtonDel" runat="server" OnClientClick='javascript:deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>")' >LinkButtonDel</asp:LinkButton>
</ItemTemplate>
但还问题.
我在调试时,看到上面的代码变成了,如下:
<a onclick="deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>");" id="ProGrid__ctl4_LinkButtonDel" href="javascript:__doPostBack('ProGrid$_ctl4$LinkButtonDel','')">LinkButtonDel</a>
请高手解决!
我按您们教的,使用了
<asp:LinkButton ID="LinkButtonDel" runat="server" OnClientClick='javascript:deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>")' >LinkButtonDel</asp:LinkButton>
</ItemTemplate>
但还问题.
我在调试时,看到上面的代码变成了,如下:
<a onclick="deleteit("<%# DataBinder.Eval(Container.DataItem,"P_ID") %>");" id="ProGrid__ctl4_LinkButtonDel" href="javascript:__doPostBack('ProGrid$_ctl4$LinkButtonDel','')">LinkButtonDel</a>
请高手解决!
#6
在后台邦定事件中做
private void dgData_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
rpAddress = e.Item.FindControl("LinkButtonDel") as LinkButton;
LinkButton..Attributes.Add("onclick", "javascript:deleteit(" + e.Item.Cells[0].Text + ")");
}
}
在前台控键中加<asp:boundcolumn datafield="P_ID"></asp:boundcolumn>作为第一列
private void dgData_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
rpAddress = e.Item.FindControl("LinkButtonDel") as LinkButton;
LinkButton..Attributes.Add("onclick", "javascript:deleteit(" + e.Item.Cells[0].Text + ")");
}
}
在前台控键中加<asp:boundcolumn datafield="P_ID"></asp:boundcolumn>作为第一列
#7
行 177: <asp:LinkButton ID="LinkButtonDel" runat="server"
OnClientClick=javascript: deleteit(' <%#DataBinder.Eval(Container.DataItem,"P_ID")') %> > LinkButtonDel </asp:LinkButton>
直接这样写试试,不太标准
最好在itemdatabind事件中写
OnClientClick=javascript: deleteit(' <%#DataBinder.Eval(Container.DataItem,"P_ID")') %> > LinkButtonDel </asp:LinkButton>
直接这样写试试,不太标准
最好在itemdatabind事件中写
#8
请问一下bayo:
rpAddress是怎么来的?
rpAddress是怎么来的?