我想在警告框中显示名称,然后在网格视图的格式中单击警告框的确定按钮,并在gridview中更新或删除属性,在另一个警告框中显示该名称及其ID。任何机构都有解决方案所以请提供
解决方案Hello Masroor, 如果我正确理解你的问题那么请参考这 [ ^ ]文章。它显示了如何使用gridview进行INSERT / UPDATE。 现在我们假设您要通过首先显示名称来确认删除操作,然后再显示另一个显示名称和ID的确认。在这种情况下,您可以连接以下JavaScript函数。 function confirmDelete(strName,strId){ var r = confirm( 将删除 + strName); if (r == true ){r = confirm( 将删除id为 + strId + 的记录并命名为 + strName); if (r == true ) return true ; } 返回 false ; }
javascript连接将在gridview的 RowDataBound 事件中完成。因此,请从上面文章中显示的aspx文件中删除onClientClick代码。代码中的连接代码将如下所示:
protected void GridView1_OnRowDataBound( object sender,GridViewRowEventArgs e){ try { if (e.Row.RowType == DataControlRowType.DataRow){ DataRowView drEachRow =(DataRowView)e.Row 。数据项; LinkButton lbBind =(LinkButton)e.Row.FindControl( lnkRemove); lbBind.Attributes.Add( onclick, javascript:return confirmDelete(' + DataBinder.Eval(e.row.DataItem,) ContactName)+ ',' + DataBinder.Eval(e.row.DataItem, CustomerID)+ ');); } } catch (例外objExp){ // 处理异常 } }问候,
I want to display name in alert box and then display that name with its id in another alert box by clicking ok button of alert box in the format of grid view with having property to update or delete within gridview. Any body have a solution so please provide
解决方案 Hello Masroor, If I understand your question correctly then please refer to this[^] article. It shows how to do INSERT/UPDATE using a gridview. Now lets assume that you want to confirm the delete operation by first displaying the name, followed by another confirm showing the name and the id. In that case you can hook up following JavaScript function. function confirmDelete(strName, strId) { var r = confirm("Will delete " + strName); if (r == true) { r = confirm("Will delete record having id " + strId + " and name " + strName); if (r == true) return true; } return false; }The javascript wiring will be done in RowDataBound event of the gridview. So do remove the onClientClick code from the aspx file shown in above article. The wiring up code in your code behind will be something like one shown below.
protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e ) { try { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drEachRow = (DataRowView) e.Row.DataItem; LinkButton lbBind= (LinkButton )e.Row.FindControl("lnkRemove"); lbBind.Attributes.Add("onclick", "javascript:return confirmDelete('" + DataBinder.Eval(e.row.DataItem, "ContactName") + "', '" + DataBinder.Eval(e.row.DataItem, "CustomerID") + "');"); } } catch(Exception objExp) { // handle exception } }Regards,
更多推荐
通过单击警告框的“确定”按钮在警报框中显示数据
发布评论