点击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;
}
我的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;
}
CommandArgument="<%#Eval("UserEducationID") %>" <%# %>块会被自动解析成值,引号不会影响到外面的。
已经找到原因了
因为有验证控件,这些按钮的属性改一下就好了
结贴了,谢谢。
用Command事件。、。。设置CommandName属性,比如等于:lbtnAbcCommand事件中判断if(e.CommandName == “lbtnAbc”)
{
//这里再写执行代码
}
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();
}
http://www.cnblogs.com/insus/articles/2036884.html