gridview删除
“/”应用程序中的服务器错误。--------------------------------------------------------------------------------
当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: 当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。
源错误:
行 37: protected void gvBookInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
行 38: {
行 39: DialogResult result = MessageBox.Show("确实要删除吗?", "操作提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
行 40: if (result == DialogResult.Yes)
行 41: {
在本机上已调试好了,但用iis浏览就出现问题。是什么原因,要怎么改好呢。。。。。。
删除的代码是这样的:
protected void gridview2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DialogResult result = MessageBox.Show("确实要删除吗?", "操作提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
string bookid = (string)gridview2.DataKeys[e.RowIndex]["Bookid"].ToString();
try
{
BLL.Bbook b = new BLL.Bbook();
b.DelteBookInfo(bookid);
Response.Write("<script>alert('删除成功!')</script>");
}
catch
{
Response.Write("<script>alert('删除失败!')</script>");
}
BinDate();
}
}
--------------------编程问答-------------------- “/”应用程序中的服务器错误。
--------------------------------------------------------------------------------
未将对象引用设置到对象的实例。
--------------------编程问答-------------------- Web程序上怎么能用MessageBox呢?
简直荒唐! --------------------编程问答--------------------
哈哈可以用的啊! --------------------编程问答--------------------
不能用这个弹出窗体的/. --------------------编程问答-------------------- 学web开发先搞清什么是服务器端,什么是客户端;什么是http协议。 --------------------编程问答-------------------- web里面使用的是alert,confirm等方法 --------------------编程问答-------------------- 你应该在绑定的时候加
比如OnClientClick="return confirm('真的要删除?')" --------------------编程问答-------------------- <asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" onrowcommand="GridView1_RowCommand"
CellPadding="4" ForeColor="#333333" GridLines="None" Font-Size="12px"
AllowPaging="True" PageSize="6"
onpageindexchanging="GridView1_PageIndexChanging">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="rid" HeaderText="rid">
<ControlStyle CssClass="hidden" />
<FooterStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
<ItemStyle CssClass="hidden" />
</asp:BoundField>
<asp:TemplateField HeaderText="招聘主题">
<ItemTemplate>
<a target="_blank" href="../jobs/showjobs.aspx?rid=<%# Eval("rid") %>"><%# Eval("title") %></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="job" HeaderText="职位名称" />
<asp:BoundField DataField="city" HeaderText="工作地点" />
<asp:BoundField DataField="number" HeaderText="招聘人数" />
<asp:BoundField DataField="pay" HeaderText="薪资水平" >
<HeaderStyle Width="80px" />
</asp:BoundField>
<asp:TemplateField HeaderText="应聘人数">
<ItemTemplate>
<a href="toemploy.aspx?rid=<%# Eval("rid") %>"><%# Eval("applynum") %></a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="添加时间">
<ItemTemplate>
<%#Common.TimeChange.ToSystemTime(Eval("addtime").ToString())%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="更新时间">
<ItemTemplate>
<%#Common.TimeChange.ToSystemTime(Eval("updatetime").ToString())%>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField CommandName="renew" Text="更新" />
<asp:ButtonField CommandName="amend" Text="修改" />
<asp:ButtonField CommandName="del" Text="删除" />
</Columns>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("amend"))
{
Response.Redirect("updaterecruit.aspx?rid=" + GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text);
}
else if (e.CommandName.Equals("del"))
{
if (Wpk.updateRecruit(GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text) > 0)
{
bind();
}
}
else if (e.CommandName.Equals("renew"))
{
if (Wpk.updateRecruit(GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text,"0") > 0)
{
bind();
}
}
else { }
--------------------编程问答-------------------- 参见
http://dotnet.aspx.cc/file/Add-confirm-dialog-with-ButtonField-Column-of-GridView.aspx --------------------编程问答-------------------- MessageBox.Show
这个真不可以.... --------------------编程问答--------------------
你这样试试
MessageBox("xxxxx");
................... --------------------编程问答-------------------- ClientScript.RegisterStartupScript(this.GetType(), "message", " <script language='javascript' >if(Confirm('确认码?'))document.getElementById('"+Hf.ClientID+"').value='1'; else document.getElementById('"+Hf.ClientID+"').value='0'; </script>");
if(Hf.Value.Equals("1"))
{
}
补充:.NET技术 , C#