Click here to Skip to main content
15,887,683 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDatagrid add column Pin
eagertolearn23-Oct-06 6:46
eagertolearn23-Oct-06 6:46 
AnswerRe: Datagrid add column Pin
Mike Ellison23-Oct-06 8:51
Mike Ellison23-Oct-06 8:51 
GeneralRe: Datagrid add column Pin
eagertolearn23-Oct-06 12:17
eagertolearn23-Oct-06 12:17 
GeneralRe: Datagrid add column Pin
Mike Ellison23-Oct-06 12:49
Mike Ellison23-Oct-06 12:49 
QuestionMTOM WSE 3.0 problem Pin
sunsmile23-Oct-06 6:11
sunsmile23-Oct-06 6:11 
QuestionUse different databases Pin
shapper23-Oct-06 5:10
shapper23-Oct-06 5:10 
AnswerRe: Use different databases Pin
ednrgc23-Oct-06 6:28
ednrgc23-Oct-06 6:28 
QuestionHow to develop a user control? Pin
Old Gun23-Oct-06 1:32
Old Gun23-Oct-06 1:32 
I get a example of FixedDataGrid Written by Alexander Zeitler.His example work well.It is fixed datagrid row height.I want to add some other function to it,such as highlight entire row,The highlight row work well,but the delete ,edit ,update command work failed!
the all code is here,Can anyone give some help?

using System;
using System.IO;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//using CustomControls;



namespace WinDataGrid
{
public class FixedHeightGrid : System.Web.UI.WebControls.DataGrid
{
private bool _mergePaddingColumns;
private TableItemStyle _paddingItemStyle = new TableItemStyle();
private int _RowHeight = 22;
private string _sRowForColor = "white";
private string _sRowBackColor = "lightblue";
public FixedHeightGrid()
{
this.ShowFooter=false;
this.ShowHeader=true;
this.AllowPaging=true;
}
public bool MergePaddingColumns
{
get {return _mergePaddingColumns;}
set {_mergePaddingColumns = value;}
}

public TableItemStyle PaddingItemStyle
{
get {return _paddingItemStyle;}
set {_paddingItemStyle = value;}
}

public int RowHeight
{
get { return _RowHeight;}
set {_RowHeight = value;}
}
public string RowForColor
{
get { return _sRowForColor;}
set {_sRowForColor = value;}
}
public string RowBackColor
{
get { return _sRowBackColor;}
set {_sRowBackColor = value;}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
AddPaddingItems();
}
protected override void OnItemCreated(DataGridItemEventArgs e)
{
base.OnItemCreated(e);
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = '" + _sRowBackColor + "';");
e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '" + _sRowForColor + "';");
}
}

private void AddPaddingItems()
{
int indexCount;
int indexStop = this.PageSize;
int indexStart = 1;
if(this.AllowPaging==true)
{
indexStart++;
indexStop++;
}
Table myTable = (Table)this.Controls[0];
for(indexCount=indexStart+this.Items.Count;indexCount<=indexStop;indexCount++)
{
myTable.Controls.AddAt(indexCount,PaddingItem());
}
}

private DataGridItem PaddingItem()
{
DataGridItem myItem = new DataGridItem(0,0,ListItemType.Item);
Table myTable = (Table)this.Controls[0];
int numberOfColumns = myTable.Rows[1].Cells.Count;
if(this.MergePaddingColumns==true)
{
TableCell myCell = new TableCell();
myCell.ColumnSpan = numberOfColumns;
myItem.Cells.Add(myCell);
}
else
{
for(int indexCount=1;indexCount<=numberOfColumns;indexCount++)
{
TableCell myCell = new TableCell();
myCell.Height = _RowHeight;
myItem.Cells.Add(myCell);
}
}
if(this.PaddingItemStyle.CssClass!=null)
{
myItem.ApplyStyle(this.PaddingItemStyle);
}
return myItem;
}
}

public class BoundColumn : System.Web.UI.WebControls.BoundColumn
{

}
public class ButtonColumn : System.Web.UI.WebControls.ButtonColumn
{

}
public class EditCommandColumn : System.Web.UI.WebControls.EditCommandColumn
{

}

public class HyperLinkColumn : System.Web.UI.WebControls.HyperLinkColumn
{

}

public class TemplateColumn : System.Web.UI.WebControls.TemplateColumn
{

}
}
AnswerRe: How to develop a user control? Pin
ednrgc23-Oct-06 4:21
ednrgc23-Oct-06 4:21 
GeneralRe: How to develop a user control? Pin
Old Gun24-Oct-06 3:30
Old Gun24-Oct-06 3:30 
GeneralRe: How to develop a user control? Pin
Old Gun26-Oct-06 3:22
Old Gun26-Oct-06 3:22 
GeneralRe: How to develop a user control? Pin
Old Gun26-Oct-06 3:23
Old Gun26-Oct-06 3:23 
QuestionDropDownList Databinding Question Pin
Dayekh23-Oct-06 1:24
Dayekh23-Oct-06 1:24 
AnswerRe: DropDownList Databinding Question Pin
Paddy Boyd23-Oct-06 3:30
Paddy Boyd23-Oct-06 3:30 
GeneralRe: DropDownList Databinding Question Pin
Dayekh23-Oct-06 3:57
Dayekh23-Oct-06 3:57 
GeneralRe: DropDownList Databinding Question Pin
Paddy Boyd23-Oct-06 4:14
Paddy Boyd23-Oct-06 4:14 
GeneralRe: DropDownList Databinding Question Pin
Dayekh23-Oct-06 5:01
Dayekh23-Oct-06 5:01 
GeneralRe: DropDownList Databinding Question Pin
Paddy Boyd23-Oct-06 5:02
Paddy Boyd23-Oct-06 5:02 
QuestionRegarding flash intro Pin
rajesh22523-Oct-06 1:10
rajesh22523-Oct-06 1:10 
AnswerRe: Regarding flash intro Pin
ednrgc23-Oct-06 2:44
ednrgc23-Oct-06 2:44 
AnswerRe: Regarding flash intro Pin
Britney S. Morales23-Oct-06 3:52
Britney S. Morales23-Oct-06 3:52 
GeneralRe: Regarding flash intro Pin
ednrgc23-Oct-06 6:34
ednrgc23-Oct-06 6:34 
Questiondrag and drop the items between 2 listboxes Pin
gane838323-Oct-06 0:05
gane838323-Oct-06 0:05 
QuestionDoes anybody know how to write hidden field using Vbscript in ASP.net 2.0? Pin
GaryWoodfine 22-Oct-06 23:56
professionalGaryWoodfine 22-Oct-06 23:56 
AnswerRe: Does anybody know how to write hidden field using Vbscript in ASP.net 2.0? Pin
Guffa23-Oct-06 0:36
Guffa23-Oct-06 0:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.