gridview添加,删除,编辑DropDownList 根据值对应相应的选择项
2009-09-08 13:48
441 查看
前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ComanyBM.aspx.cs" Inherits="ComanyBM" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<link href="Css/StyleSheet.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 90%">
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"
ShowFooter="True" Width="100%" DataKeyNames="id" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating">
<Columns>
<asp:BoundField DataField="id" HeaderText="序号" ReadOnly="True" />
<asp:TemplateField HeaderText="部门名称">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("bmmc") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("bmmc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="部门类别">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList><asp:HiddenField
ID="HiddenField1" Value='<%# Bind("bmlb") %>' runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("bmlb") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="部门权值">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("hb1") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("hb1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="是否禁用">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Qz(Eval("hb2")) %>' />
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Qz(Eval("hb2")) %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="描述">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("bz") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("bz") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/botton_gif_060.gif" OnClick="ImageButton2_Click" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<table border="1" cellspacing="0" width="100%">
<tr>
<td>
序号</td>
<td>
部门名称</td>
<td>
部门类别</td>
<td>
部门权值</td>
<td>
是否禁用</td>
<td>
描述</td>
<td>
操作</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList></td>
<td>
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox></td>
<td>
<asp:CheckBox ID="CheckBox3" runat="server" /></td>
<td>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox></td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/botton_gif_060.gif"
OnClick="ImageButton1_Click" /></td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
后台代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ComanyBM : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Query();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
private void Query()
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
GridView1.DataSource = obj.GetList("");
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((DropDownList)e.Row.FindControl("DropDownList2") != null)
{
if ((e.Row.RowState & DataControlRowState.Edit) != 0)
{
DropDownList dl = (DropDownList)e.Row.FindControl("DropDownList2");
if (dl != null)
{
JSOA.Co.DropListBind.DropBind(dl, "3");
// 选中 DropDownList
HiddenField dtm = (HiddenField)e.Row.Cells[2].FindControl("HiddenField1");
string dd = dtm.Value;
dl.SelectedIndex = dl.Items.IndexOf(dl.Items.FindByValue(dtm.Value.ToString().Trim()));
}
}
}
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E3E3E3',this.style.color='#0a6cce'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff',this.style.color='#000000'");
e.Row.Cells[0].Text = Convert.ToString(e.Row.RowIndex + 1);//产生序号
try
{
e.Row.Cells[2].Text = JSOA.Co.DataConver.DicConver(((Label)e.Row.FindControl("Label2")).Text.ToString().Trim());
}
catch { }
}
if (e.Row.RowType == DataControlRowType.Footer)
{
if ((DropDownList)e.Row.FindControl("DropDownList1") != null)
{
DropDownList dl = (DropDownList)e.Row.FindControl("DropDownList1");
JSOA.Co.DropListBind.DropBind(dl, "3");
// 选中 DropDownList
//dl.SelectedValue = ((HiddenField)e.Row.FindControl("Label2")).Value;
//
}
}
if (e.Row.RowType == DataControlRowType.EmptyDataRow)
{
if ((DropDownList)GridView1.Controls[0].Controls[0].FindControl("DropDownList3") != null)
{
DropDownList dl = (DropDownList)GridView1.Controls[0].Controls[0].FindControl("DropDownList3");
JSOA.Co.DropListBind.DropBind(dl, "3");
// 选中 DropDownList
//dl.SelectedValue = ((HiddenField)e.Row.FindControl("Label2")).Value;
//
}
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
JSOA.Model.GSBMB Model = new JSOA.Model.GSBMB();
Model.BMMC = ((TextBox)GridView1.Controls[0].Controls[0].FindControl("TextBox2")).Text.Trim();
Model.BMLB = ((DropDownList)GridView1.Controls[0].Controls[0].FindControl("DropDownList3")).SelectedValue;
Model.BZ = ((TextBox)GridView1.Controls[0].Controls[0].FindControl("TextBox6")).Text.Trim();
Model.HB1 = ((TextBox)GridView1.Controls[0].Controls[0].FindControl("TextBox8")).Text.Trim();
if (((CheckBox)GridView1.Controls[0].Controls[0].FindControl("CheckBox3")).Checked)
{
Model.HB2 = "1";
}
else {
Model.HB2 = "0";
}
Model.LRR = "当前用户id";
Model.LRSJ = DateTime.Now;
try {
obj.Add(Model);
JSOA.Common.MessageBox.Show(this, "部门信息添加成功!");
this.Query();
}
catch { }
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
JSOA.Model.GSBMB Model = new JSOA.Model.GSBMB();
Model.BMMC = ((TextBox)GridView1.FooterRow.FindControl("TextBox4")).Text.Trim();
Model.BMLB = ((DropDownList)GridView1.FooterRow.FindControl("DropDownList1")).SelectedValue;
Model.BZ = ((TextBox)GridView1.FooterRow.FindControl("TextBox5")).Text.Trim();
Model.HB1 = ((TextBox)GridView1.FooterRow.FindControl("TextBox7")).Text.Trim();
if (((CheckBox)GridView1.FooterRow.FindControl("CheckBox2")).Checked)
{
Model.HB2 = "1";
}
else
{
Model.HB2 = "0";
}
Model.LRR = "当前用户id";
Model.LRSJ = DateTime.Now;
try
{
obj.Add(Model);
JSOA.Common.MessageBox.Show(this, "部门信息添加成功!");
this.Query();
}
catch { }
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
JSOA.Model.GSBMB Model = new JSOA.Model.GSBMB();
Model.ID = System.Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
Model.BMMC = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text.Trim();
Model.BMLB = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList2")).SelectedValue;
Model.BZ = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3")).Text.Trim();
Model.HB1 = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2")).Text.Trim();
if (((CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1")).Checked)
{
Model.HB2 = "1";
}
else {
Model.HB2 = "0";
}
Model.LRR = "当前用户id";
Model.LRSJ = DateTime.Now;
try
{
obj.Update(Model);
JSOA.Common.MessageBox.Show(this, "部门信息修改成功!");
GridView1.EditIndex = -1;
this.Query();
}
catch { }
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
this.Query();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
this.Query();
}
protected bool Qz(object qx)
{
bool Result=false;
if (qx.ToString().Trim() == "1")
{
Result = true;
}
return Result;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ComanyBM.aspx.cs" Inherits="ComanyBM" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<link href="Css/StyleSheet.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 90%">
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"
ShowFooter="True" Width="100%" DataKeyNames="id" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating">
<Columns>
<asp:BoundField DataField="id" HeaderText="序号" ReadOnly="True" />
<asp:TemplateField HeaderText="部门名称">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("bmmc") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("bmmc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="部门类别">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList><asp:HiddenField
ID="HiddenField1" Value='<%# Bind("bmlb") %>' runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("bmlb") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="部门权值">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("hb1") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("hb1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="是否禁用">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Qz(Eval("hb2")) %>' />
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" />
</FooterTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Qz(Eval("hb2")) %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="描述">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("bz") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("bz") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/botton_gif_060.gif" OnClick="ImageButton2_Click" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<table border="1" cellspacing="0" width="100%">
<tr>
<td>
序号</td>
<td>
部门名称</td>
<td>
部门类别</td>
<td>
部门权值</td>
<td>
是否禁用</td>
<td>
描述</td>
<td>
操作</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList></td>
<td>
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox></td>
<td>
<asp:CheckBox ID="CheckBox3" runat="server" /></td>
<td>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox></td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/botton_gif_060.gif"
OnClick="ImageButton1_Click" /></td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
后台代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ComanyBM : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Query();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
private void Query()
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
GridView1.DataSource = obj.GetList("");
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((DropDownList)e.Row.FindControl("DropDownList2") != null)
{
if ((e.Row.RowState & DataControlRowState.Edit) != 0)
{
DropDownList dl = (DropDownList)e.Row.FindControl("DropDownList2");
if (dl != null)
{
JSOA.Co.DropListBind.DropBind(dl, "3");
// 选中 DropDownList
HiddenField dtm = (HiddenField)e.Row.Cells[2].FindControl("HiddenField1");
string dd = dtm.Value;
dl.SelectedIndex = dl.Items.IndexOf(dl.Items.FindByValue(dtm.Value.ToString().Trim()));
}
}
}
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E3E3E3',this.style.color='#0a6cce'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff',this.style.color='#000000'");
e.Row.Cells[0].Text = Convert.ToString(e.Row.RowIndex + 1);//产生序号
try
{
e.Row.Cells[2].Text = JSOA.Co.DataConver.DicConver(((Label)e.Row.FindControl("Label2")).Text.ToString().Trim());
}
catch { }
}
if (e.Row.RowType == DataControlRowType.Footer)
{
if ((DropDownList)e.Row.FindControl("DropDownList1") != null)
{
DropDownList dl = (DropDownList)e.Row.FindControl("DropDownList1");
JSOA.Co.DropListBind.DropBind(dl, "3");
// 选中 DropDownList
//dl.SelectedValue = ((HiddenField)e.Row.FindControl("Label2")).Value;
//
}
}
if (e.Row.RowType == DataControlRowType.EmptyDataRow)
{
if ((DropDownList)GridView1.Controls[0].Controls[0].FindControl("DropDownList3") != null)
{
DropDownList dl = (DropDownList)GridView1.Controls[0].Controls[0].FindControl("DropDownList3");
JSOA.Co.DropListBind.DropBind(dl, "3");
// 选中 DropDownList
//dl.SelectedValue = ((HiddenField)e.Row.FindControl("Label2")).Value;
//
}
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
JSOA.Model.GSBMB Model = new JSOA.Model.GSBMB();
Model.BMMC = ((TextBox)GridView1.Controls[0].Controls[0].FindControl("TextBox2")).Text.Trim();
Model.BMLB = ((DropDownList)GridView1.Controls[0].Controls[0].FindControl("DropDownList3")).SelectedValue;
Model.BZ = ((TextBox)GridView1.Controls[0].Controls[0].FindControl("TextBox6")).Text.Trim();
Model.HB1 = ((TextBox)GridView1.Controls[0].Controls[0].FindControl("TextBox8")).Text.Trim();
if (((CheckBox)GridView1.Controls[0].Controls[0].FindControl("CheckBox3")).Checked)
{
Model.HB2 = "1";
}
else {
Model.HB2 = "0";
}
Model.LRR = "当前用户id";
Model.LRSJ = DateTime.Now;
try {
obj.Add(Model);
JSOA.Common.MessageBox.Show(this, "部门信息添加成功!");
this.Query();
}
catch { }
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
JSOA.Model.GSBMB Model = new JSOA.Model.GSBMB();
Model.BMMC = ((TextBox)GridView1.FooterRow.FindControl("TextBox4")).Text.Trim();
Model.BMLB = ((DropDownList)GridView1.FooterRow.FindControl("DropDownList1")).SelectedValue;
Model.BZ = ((TextBox)GridView1.FooterRow.FindControl("TextBox5")).Text.Trim();
Model.HB1 = ((TextBox)GridView1.FooterRow.FindControl("TextBox7")).Text.Trim();
if (((CheckBox)GridView1.FooterRow.FindControl("CheckBox2")).Checked)
{
Model.HB2 = "1";
}
else
{
Model.HB2 = "0";
}
Model.LRR = "当前用户id";
Model.LRSJ = DateTime.Now;
try
{
obj.Add(Model);
JSOA.Common.MessageBox.Show(this, "部门信息添加成功!");
this.Query();
}
catch { }
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
JSOA.BLL.GSBMB obj = new JSOA.BLL.GSBMB();
JSOA.Model.GSBMB Model = new JSOA.Model.GSBMB();
Model.ID = System.Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
Model.BMMC = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text.Trim();
Model.BMLB = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList2")).SelectedValue;
Model.BZ = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3")).Text.Trim();
Model.HB1 = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2")).Text.Trim();
if (((CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1")).Checked)
{
Model.HB2 = "1";
}
else {
Model.HB2 = "0";
}
Model.LRR = "当前用户id";
Model.LRSJ = DateTime.Now;
try
{
obj.Update(Model);
JSOA.Common.MessageBox.Show(this, "部门信息修改成功!");
GridView1.EditIndex = -1;
this.Query();
}
catch { }
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
this.Query();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
this.Query();
}
protected bool Qz(object qx)
{
bool Result=false;
if (qx.ToString().Trim() == "1")
{
Result = true;
}
return Result;
}
}
相关文章推荐
- 关于在GridView模版里添加DropDownList实现根据下拉列表的不同选择gridview根据条件筛选显示。
- 使用XmlDocument将dropdownlist中显示的书名的其它信息读入到相应的文本框中。添加 :删除按钮,修改并保存按钮 和 添加按钮。完成这些按钮所对应的功能(XmlDocument)
- ASP.NET GridView用法(二) 模板,脚注,排序,编辑,删除,多选,分页,添加
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!
- 使用GridView添加,删除,编辑记录
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!2
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!10
- 关于gridview如何添加编辑删除
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!
- Gridview中的选择、删除、编辑、更新、取消留着备用。
- GridView 实现自定义分页、排序、查询、添加、编辑、多选删除、导出、突出显示等常见应用实现(cs)
- GridView 实现自定义分页、排序、查询、添加、编辑、多选删除 之代码规范
- GridView的选择、取消、编辑、删除、更新事件代码
- GridView 编辑、删除、【含有dropdownlist、fileupload、Image控件】
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!3
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!10
- DevExpress GridControl控件行内新增、编辑、删除添加选择框
- 第一次提问题--根据dropdownlist 的选择而动态显示或隐藏GridView的某些字段!!