一、使用TemplateColumn:
在Property Builder对话框中,将该列换成Template,关闭对话框。
在DataGrid上右击,选编辑Template中的那一列,然后就可以在里面放入你所要的编辑控件。
二、通过事件ItemCreated完成:
在事件中:
if( e.Item.ItemType == ListItemType.EditItem )
{
TextBox t = new TextBox();
t.TextMode = TextMode.MultiLine;
e.Item.Cells[n].Controls.Clear();
e.Item.Cells[n].Controls.Add(t);
// n 为所要的列
}
在Property Builder对话框中,将该列换成Template,关闭对话框。
在DataGrid上右击,选编辑Template中的那一列,然后就可以在里面放入你所要的编辑控件。
二、通过事件ItemCreated完成:
在事件中:
if( e.Item.ItemType == ListItemType.EditItem )
{
TextBox t = new TextBox();
t.TextMode = TextMode.MultiLine;
e.Item.Cells[n].Controls.Clear();
e.Item.Cells[n].Controls.Add(t);
// n 为所要的列
}
解决方案 »
- 窗体2中有个PictureBOX1 窗体3中有一个Button1,这两个状体都在同一个解决方案之下。如何用窗体3中Button1控制窗体2中PictureBOX
- C#Remove()方法问题
- #标题党#请问在winform中,如何控制单价输入
- 加入难题??
- winform中datagrid 的导航的问题
- 关于动态编译的问题?(UP有分)
- 请教关于泛类型
- 好象都说软设没有啊。那大家认为系分如何(作用,难度)?还有系分的有效期多久啊?也是三年么?
- 关于Console.WriteLine()输出的问题
- .Net是否可以实现和java的applet类似的效果?
- 请问在TabControl中如何关闭当前的TabPage??
- c#有某类向recordset中的movenext,没有怎么movenext
"Understanding Templates in ASP.NET"
http://msdn.microsoft.com/msdnmag/issues/02/01/cutting/cutting0201.aspfor an example
在
private void DataGrid_Update(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//DropDownList DropDownList1 = (DropDownList)e.Item.Cells[9].Controls[0]; //status code
错误为:无法造型(Cast).
他几个范例我看不懂呀。
我该如何在 DataGrid_Update事件里得到那个 DropDownList 的值呢?
大家再帮帮我好吗?
我一定给分的
{
int UserID =(int)DataGrid1.DataKeys[(int)E.Item.ItemIndex]; string UserName = ((TextBox)E.Item.Cells[1].Controls[0]).Text;
string Password=((TextBox)E.Item.Cells[2].Controls[0]).Text;
string UserType = ((TextBox)E.Item.Cells[3].Controls[0]).Text;
string UserRole = ((TextBox)E.Item.Cells[4].Controls[0]).Text;
string UserClass = ((TextBox)E.Item.Cells[5].Controls[0]).Text; string strSql="UPDATE DevUser set UserName='" + UserName + "',Pwd='" + Password + "',UserType='" + UserType + "',UserRole='" + UserRole + "',UserClass='" + UserClass + "' where UserID=" + UserID; string connstr=ConfigurationSettings.AppSettings["OleDbString"];
OleDbConnection MyConnection=new OleDbConnection(connstr);
MyConnection.Open(); OleDbCommand myCommand2= new OleDbCommand(strSql, MyConnection);
myCommand2.CommandType=CommandType.Text;
myCommand2.ExecuteNonQuery(); DataGrid1.EditItemIndex = -1;
List();
}
例如:<BR>
<ItemTemplate><BR>
<ASP:DropDownList runat="Server" ID="ddlDropDownList"></ASP:DropDownList>
<ItemTemplate><BR>
然后使用FindControl.<BR>
DropDownList ddlDropDownList1=(DropDownList)e.Item.FindControl("ddlDropDownList");
给我的简单的方法。
大家都有
昨天我看sdk都看昏了,跳来跳去~新版我连给分都不会了,我再试试