protected void ImageButton1_Command(object sender, CommandEventArgs e)
{
int typeid = 0;
typeid = Convert.ToInt32(e.CommandArgument);
Response.Write("<script>OpenSubWindow('UpdateDisasterType.aspx?id=" + typeid + "','300','300');</script>");
}
ImageButton1是gridview中模板列中添加的一个imagebutton,我想要实现的是点击imagebutton时出现一个弹不框,为什么我点了出现的是所选的那行成了编辑状态呢,请高手赐教!
{
int typeid = 0;
typeid = Convert.ToInt32(e.CommandArgument);
Response.Write("<script>OpenSubWindow('UpdateDisasterType.aspx?id=" + typeid + "','300','300');</script>");
}
ImageButton1是gridview中模板列中添加的一个imagebutton,我想要实现的是点击imagebutton时出现一个弹不框,为什么我点了出现的是所选的那行成了编辑状态呢,请高手赐教!
{
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
{ ImageButton imgDel=(ImageButton)e.Item.FindControl("ImageButton1");
int typeid = 0;
typeid = Convert.ToInt32(e.CommandArgument);
// Response.Write(" <script>OpenSubWindow('UpdateDisasterType.aspx?id=" + typeid + "','300','300'); </script>");
imgDel.Attributes.Add("onclick","OpenSubWindow('UpdateDisasterType.aspx?id=" + typeid + "','300','300');");
}
}
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ImageButton delete = (ImageButton)e.Item.FindControl("按钮的id");
delete.Attributes.Add("onclick", "你要调用的方法");
}
}
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function OpenSubWindow(frmWin,width,height)
{
window.showModalDialog(frmWin,window,'dialogWidth='+width+'px;dialogHeight='+height+'px;help:no;status:no;toolbar:no')
}
</script>
<script language="javascript">
function openwin() {
var obj=document.getElementById("HiddenField1");
var objempid=document.getElementById("HiddenField2");
var objemprole=document.getElementById("HiddenField3");
window.open('AdminEmpRole.aspx?typeid='+obj.value+ '&empid='+objempid.value+ '&emprole='+objemprole.value+'','_blank','fullscreen=3,titlebar=no,toolbar=no, location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=yes, edge:Raised,left=360,top=100,width=200,height=500,false');
}
</script>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<div style="text-align: center">
<table border="1" cellpadding="1" cellspacing="0" style="width: 434px; height: 105px">
<tr>
<td colspan="2" style="text-align: left">
受灾类型添加</td>
</tr>
<tr>
<td style="width: 100px">
类型:</td>
<td style="width: 100px">
<asp:TextBox ID="txtType" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnOk" runat="server" Text="确定" Width="69px" OnClick="btnOk_Click"/>
<asp:Button ID="btnCancel" runat="server" Text="取消" Width="71px" OnClick="btnCancel_Click" /></td>
</tr>
</table>
<br />
</div>
<table>
<tr>
<td style="width: 468px; height: 232px;">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="disastertype" Width="483px" DataKeyNames="sjid" OnDataBound="GridView1_DataBound">
<Columns>
<asp:BoundField DataField="sjid" HeaderText="编号" InsertVisible="False" ReadOnly="True"
SortExpression="sjid" />
<asp:BoundField DataField="sjzhi" HeaderText="受灾类型" SortExpression="sjzhi" />
<asp:BoundField DataField="xiugairen" HeaderText="修改人" SortExpression="xiugairen" />
<asp:BoundField DataField="xiugaishijian" HeaderText="修改时间" SortExpression="xiugaishijian" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/MiniUI/images/bianji.gif" CommandArgument ='<%# Eval("sjid") %> ' CommandName="edit" OnCommand="ImageButton1_Command"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/MiniUI/images/delete1.gif" OnClientClick="return confirm('确认要删除吗?');" CommandName="delete" CommandArgument ='<%# Eval("sjid") %> ' OnCommand="ImageButton2_Command" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="disastertype" runat="server" ConnectionString="<%$ ConnectionStrings:jzsjConnectionString %>"
SelectCommand="SELECT shujuzidian.* FROM shujuzidian where sjguanjianzi = @sjguanjianzi and sjzhuangtai = @sjzhuangtai">
<SelectParameters>
<asp:Parameter DefaultValue="disasterType" Name="sjguanjianzi" />
<asp:Parameter DefaultValue="1" Name="sjzhuangtai" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</form>
</body>
</html>
这是我前台的代码,怎么gridview里没有ItemDataBound事件啊