点击linkbutton的时候底下显示的是这个
我的linkbutton在repeater里 <asp:Repeater ID="rp_edution" runat="server" OnItemDataBound="rp_edution_ItemDataBound">
   <ItemTemplate>
 <div class="height25 margin-bottom10">
                       <!--省略的一些东西-->
               <asp:LinkButton ID="lbtn_xg" runat="server" CommandArgument='<%#Eval("UserEducationID") %>'OnClick="lbtn_xg_Click">修改</asp:LinkButton>
        </div>
    </ItemTemplate>
 </asp:Repeater>
跟后台的linkbutton事件应该没什么关系吧protected void lbtn_xg_Click(object sender, EventArgs e)
    {
        //Response.Write("<script>alert('a')</script>");
        int id = Convert.ToInt32(((LinkButton)sender).CommandArgument);
        lbl_schoolId.Text = id.ToString();
        // div1.Style["display"] = "block";
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>showDiv('div1');</script>");
        DB_UserEducation edu = DB_UserEducationManager.getUserEducationById(id);
        ddp_accschool.SelectedValue = edu.AccessRight.ToString();
        txt_department.Text = edu.SchoolDepartment;
        txt_schoolName.Text = edu.SchoolName;
        txt_special.Text = edu.Specialty;
        ddp_school.SelectedValue = edu.SchoolType;
        ddp_time.SelectedValue = edu.EnterTag.ToString().Substring(0, 4);
        img_xgschool.Visible = true;
        img_tjschool.Visible = false;
    }

解决方案 »

  1.   

    应该猜后台绑定,使用的是服务器空间,应该在后台formload中绑定js事件
      

  2.   

    没有设置CommandName嘛。CommandArgument='<%#Eval("UserEducationID") %>'这个改成双引号也没关系啊
    CommandArgument="<%#Eval("UserEducationID") %>"    <%# %>块会被自动解析成值,引号不会影响到外面的。
      

  3.   

    我这个不需要commandName
    已经找到原因了
    因为有验证控件,这些按钮的属性改一下就好了
    结贴了,谢谢。
      

  4.   

    我明白了,你的响应事件写错地方了。你的linkbutton是在repeater中的,你的事件委托需要定义在repeater的OnItemCommand事件中,然后通过CommandName分辨事件属于什么事件。
      

  5.   


    用Command事件。、。。设置CommandName属性,比如等于:lbtnAbcCommand事件中判断if(e.CommandName == “lbtnAbc”)
    {
       //这里再写执行代码
    }
      

  6.   

    跟这种情况类型类似:<asp:ListView runat="server" ID="ProjectList" 
                        onitemdatabound="ProjectList_ItemDataBound" 
                        onitemcommand="ProjectList_ItemCommand">
                        <LayoutTemplate>
                            <tr runat="server" id="itemPlaceholder" />
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr class="toptd" onmouseover="this.className='topovertd';" onmouseout="this.className='toptd';">
                                <td>
                                    <img src="Common/images/iconselect/<%# Eval("fIconUrl") %>" width="52" height="52"
                                        class="liststyleimgleft" alt="<%#Eval("fProjectName")%>" />
                                </td>
                                <td>
                                    <%#Eval("fProjectName")%>
                                </td>
                                <td>
                                    <%#Eval("fModifyDate")%>
                                </td>
                                <td>
                                    <asp:Label ID="fProjectId" runat="server" Visible="false" Text='<%# Eval("fProjectId") %>'></asp:Label>
                                    <asp:LinkButton ID="Save" runat="server" Text="管理" CommandName="Save"></asp:LinkButton>
                                    <asp:LinkButton ID="Del" runat="server" Text="取消" ForeColor="red"  CommandName="Del"></asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>
    后台代码:protected void ProjectList_ItemCommand(object sender, ListViewCommandEventArgs e)
            {
                if (e.CommandName == "Save")
                {
                    Label hf = e.Item.FindControl("fProjectId") as Label;
                    if (hf != null)
                    {
                        int pid = Convert.ToInt32((hf.Text == null || hf.Text.Length == 0) ? "0" : hf.Text);
                        // 修改操作
                    }
                }
                else if (e.CommandName == "Del")
                {
                    Label hf = e.Item.FindControl("fProjectId") as Label;
                    if (hf != null)
                    {
                        int pid = Convert.ToInt32((hf.Text == null || hf.Text.Length == 0) ? "0" : hf.Text);
                        // 删除操作
                    }
                }            // 刷新列表数据
                initProjectList();
            }
      

  7.   

    参考这篇,如何取得Repeater的主键:
    http://www.cnblogs.com/insus/articles/2036884.html