add a confirm dialogbox to the editItem of the datagrid
2005-09-16 09:20
639 查看
//first add a delegate in private void InitializeComponent()
this.DataGrid1.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemCreated);
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType lit = e.Item.ItemType;
if (lit == ListItemType.Item || lit == ListItemType.AlternatingItem)
{
CustomizeItem(e);
}
}
private void CustomizeItem(DataGridItemEventArgs e)
{
WebControl wc;
int i = e.Item.Cells.Count -1;
wc = ((WebControl) e.Item.Cells[i]);
wc.Height = 25;//set the item's style
wc.Width = 25;
String js = "return confirm("Delete it?");";
wc.Attributes.Add("onclick", js);
// wc.ToolTip = e.Item.Cells[0].Text.Trim() + "...";
wc.ToolTip += "Delete this row";
}
this.DataGrid1.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemCreated);
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType lit = e.Item.ItemType;
if (lit == ListItemType.Item || lit == ListItemType.AlternatingItem)
{
CustomizeItem(e);
}
}
private void CustomizeItem(DataGridItemEventArgs e)
{
WebControl wc;
int i = e.Item.Cells.Count -1;
wc = ((WebControl) e.Item.Cells[i]);
wc.Height = 25;//set the item's style
wc.Width = 25;
String js = "return confirm("Delete it?");";
wc.Attributes.Add("onclick", js);
// wc.ToolTip = e.Item.Cells[0].Text.Trim() + "...";
wc.ToolTip += "Delete this row";
}
相关文章推荐
- Animate to display a dialog message box in the right-bottom of the window screen
- add line order to each line and remove the last match of each line
- How to implement popup Calendar dialog box with DataGrid
- source insight Confirm by typing ‘yes' below"、"has been changed outside of the editor. Do you want to reload the file?"、“
- add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.(转载)
- R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)
- iOS通知 you still need to add "remote-notification" to the list of your supported UIBackgroundModes
- 解决Failed to add the host to the list of known hosts
- Adding Assemblies to the Visual Studio "Add Reference" Dialog(收集)
- How to change the background color of an Edit Box
- How to add icon for the item of ListCtrl using C++ (Mail Attachment ListCtrl) - 如何用C++为ListCtrl的Item添加图标(邮件附件ListCtrl)
- Add a function called trim as a method of the prototype (similar to VBScript's Trim function)
- PowerTip of the Day-Add Help to Your Functions
- createDataSource, and add new rows on the datagrid to be filled out.
- How to make our assemblies appeared in Add Reference dialog box
- add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
- svn问题之一: Failed to add file 'xxx': an unversioned file of the same name already exists
- 错误解决:Unable to add module to the current project as it is not of packagi
- Unable to add module to the current project as it is not of packaging type 'pom' 问题解决
- How to: Display a Dialog Box for Selecting Entries from the Contacts Folder