gridview和自定义BUTTON的问题
序号姓名单位|
1 aa tt |
2 bb yy |
3 cc uu |
4 dd ii |gridview
-----------------------
序号___ (textbox)
姓名___ (textbox)
单位___ (textbox)
button1→删除 button2→更新
选定一行后自动填充在下方的textbox中序号、姓名、单位中,点删除按钮后gridview就删除一行。(要有删除提示)
各位高手,前面我没写清楚。请各位赐教。
------解决方案--------------------部分代码:
aspx:
<div>
<asp:GridView ID= "GridView1 " runat= "server " AutoGenerateColumns= "False ">
<Columns>
<asp:BoundField DataField= "OrderID " HeaderText= "OrderID " />
<asp:BoundField DataField= "Name " HeaderText= "Name " />
<asp:BoundField DataField= "Department " HeaderText= "Department " />
<asp:TemplateField HeaderText= "Action ">
<ItemTemplate >
<asp:LinkButton ID= "btnSelect " runat= "server " Text= "Select " OnClick= "btnSelect_Click "> </asp:LinkButton>
<asp:LinkButton ID= "btnDel " runat= "server " Text= "Delete " OnClick= "btnDel_Click " CommandArgument= ' <%# DataBinder.Eval(Container.DataItem, "OrderID ") %> ' OnClientClick= "javascript:return window.Confirm( 'Are you sure to delete this record ? ') "> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<ul>
OrderID:
<asp:TextBox ID= "txtOrder " runat= "server "> </asp:TextBox>
</ul>
<ul>
Name:
<asp:TextBox ID= "txtName " runat= "server "> </asp:TextBox>
</ul>
<ul>
Department: <asp:TextBox ID= "txtDepart " runat= "server "> </asp:TextBox>
</ul>
</div>
cs:
private DataSet DataSource
{
get
{
DataRow dr=null;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn( "OrderID ", typeof(int)));
dt.Columns.Add(new DataColumn( "Name ", typeof(string)));
dt.Columns.Add(new DataColumn( "Department ", typeof(string)));
dr = dt.NewRow();
dr[ "OrderID "] = 1;
dr[ "Name "] = "James ";
dr[ "Department "] = "ProjectM ";
dt.Rows.Add(dr);
dr[ "OrderID "] = 2;
dr[ "Name "] = "Lucy ";
dr[ "Department "] = "IT ";
dt.Rows.Add(dr);
ds.Tables.Add(dt);
return ds;
}
}
protected void btnSelect_Click(object sender, EventArgs e)