在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<script type="text/javascript">
//删除
function Delete(hdGuid) {
$("#hdGuid").val(hdGuid);
$("#btnDel").click();
}
</script>
<body>
<input />
<asp:ImageButton ImageUrl="" ID="btnDel" runat="server" OnClientClick="return confirm('确认删除该入库申请?');"
OnClick="btnDel_Click" CssClass="hidden" />
。。。。。。
<cc:PagingGridView ID="GridViewData" Width="100%" runat="server" AutoGenerateColumns="False"
PageSize="20" OnBindDataSource="GridViewData_BindDataSource">
<EmptyDataTemplate>
无相关数据
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="操作">
<HeaderStyle Width="5%" />
<ItemStyle Width="5%" />
<ItemTemplate>
<a href="#" onclick="Delete('<%# Container.DataItemIndex%>')" class="aCss addreturn">
<img src="../images/DGBtn/sc.gif" alt="删除" />
</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="td1" />
<HeaderStyle CssClass="td_bthead" />
<PagerStyle CssClass="td0" />
<AlternatingRowStyle CssClass="td2" />
</cc:PagingGridView>
</div>
</form>
</body>
以上为前台代码????
后台代码: /// <summary> /// 保存临时表datatable /// </summary> protected DataTable dt0 { get { return (DataTable)ViewState["dt0"]; } set { ViewState["dt0"] = value; } } protected void btnDel_Click(object sender, ImageClickEventArgs e) { int cfs = Convert.ToInt32(cftsTB.Text); if (cfs > 1) { dt0.Rows.RemoveAt(Convert.ToInt32(hdGuid.Value)); PageDataList.BindGridView(GridViewData, dt0); cftsTB.Text = string.Format("{0}", cfs - 1); } else { PageHelper.MessageBox(this, "拆分数目需要大于1!"); } } 问题在于,①创建一个全局的临时表变量 dt0 ,用于调用和修改;②使用datatable的属性方法来进行操作、如 PageDataList.BindGridView(GridViewData, dt0);
dt0.Rows.RemoveAt(Convert.ToInt32(hdGuid.Value)); public void creatCfdt(decimal cfNum) { string result = null; ZcKcbEntity kcb = new ZcKcbAction().GetInfo(guid); DataTable data = new DataTable(); data.Columns.Add(new DataColumn("guid", System.Type.GetType("System.String"))); data.Columns.Add(new DataColumn("zcmc", System.Type.GetType("System.String"))); data.Columns.Add(new DataColumn("czcode", System.Type.GetType("System.String"))); data.Columns.Add(new DataColumn("dj", System.Type.GetType("System.Decimal"))); data.Columns.Add(new DataColumn("je", System.Type.GetType("System.Decimal"))); data.Columns.Add(new DataColumn("syr", Type.GetType("System.String"))); data.Columns.Add(new DataColumn("sybm", System.Type.GetType("System.String"))); data.Columns.Add(new DataColumn("syfx", System.Type.GetType("System.String"))); data.Columns.Add(new DataColumn("cfdd", System.Type.GetType("System.String"))); data.Columns.Add(new DataColumn("djsj", System.Type.GetType("System.DateTime"))); data.Columns.Add(new DataColumn("sl", Type.GetType("System.Decimal"))); DataRow row2 = data.NewRow(); row2["guid"] = kcb.guid; row2["zcmc"] = kcb.zcmc; row2["czcode"] = kcb.czcode; row2["dj"] = kcb.dj; row2["je"] = kcb.je; row2["syr"] = kcb.syr; row2["sybm"] = kcb.sybm; row2["syfx"] = kcb.syfx; row2["cfdd"] = kcb.cfdd; row2["djsj"] = kcb.djsj; row2["sl"] = kcb.sl - cfNum + 1; data.Rows.Add(row2); dt0 = data; if (data != null) { //绑定数据 if (!PageDataList.BindGridView(GridViewData, data)) { result = "绑定列表失败!"; } } else { result = "获取数据失败!"; } //返回结果 PageHelper.MessageBox2(this, result); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论