Hello I have some code to extend the gridview control as shown that hides the
Select button and underlines the text as you scroll on it.
I have also overridden the SelectIndexChan ged event so that it highlights
the row on selection.
I use this control on a particular form and I trigger the event
OnSelectIndexCh anged = "gridview_selec tIndexChanged" where I wish it to
carry out the normal SelectIndexchan ged event in my extended control and also
some extra stuff as shown below. It just ignores this and carries out the
default behaviour, how do I get it so that it carries out the default as well
as any extra stuff I put in .
//form with my extended gridview control in it
protected void gridview_Select IndexChanged(ob ject sender, EventArgs e)
{
//Some extra functionality goes here
}
// My Extended Grid view control
public partial class SpecialGridView : System.Web.UI.W ebControls.Grid View
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected override void OnSelectedIndex Changed(EventAr gs e)
{
for (int i = 0; i <= this.Rows.Count - 1; i++)
{
this.Rows[i].BackColor = System.Drawing. Color.White;
}
this.SelectedRo w.BackColor = System.Drawing. Color.Orange;
}
protected virtual void OnRowDataBound( GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Attribute s["onmouseove r"] =
"this.style.cur sor='hand';this .style.textDeco ration='underli ne';";
e.Row.Attribute s["onmouseout "] =
"this.style.tex tDecoration='no ne';";
e.Row.Attribute s["onclick"] =
Page.ClientScri pt.GetPostBackC lientHyperlink( this, "Select$" +
e.Row.RowIndex) ;
}
}
}
Select button and underlines the text as you scroll on it.
I have also overridden the SelectIndexChan ged event so that it highlights
the row on selection.
I use this control on a particular form and I trigger the event
OnSelectIndexCh anged = "gridview_selec tIndexChanged" where I wish it to
carry out the normal SelectIndexchan ged event in my extended control and also
some extra stuff as shown below. It just ignores this and carries out the
default behaviour, how do I get it so that it carries out the default as well
as any extra stuff I put in .
//form with my extended gridview control in it
protected void gridview_Select IndexChanged(ob ject sender, EventArgs e)
{
//Some extra functionality goes here
}
// My Extended Grid view control
public partial class SpecialGridView : System.Web.UI.W ebControls.Grid View
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected override void OnSelectedIndex Changed(EventAr gs e)
{
for (int i = 0; i <= this.Rows.Count - 1; i++)
{
this.Rows[i].BackColor = System.Drawing. Color.White;
}
this.SelectedRo w.BackColor = System.Drawing. Color.Orange;
}
protected virtual void OnRowDataBound( GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Attribute s["onmouseove r"] =
"this.style.cur sor='hand';this .style.textDeco ration='underli ne';";
e.Row.Attribute s["onmouseout "] =
"this.style.tex tDecoration='no ne';";
e.Row.Attribute s["onclick"] =
Page.ClientScri pt.GetPostBackC lientHyperlink( this, "Select$" +
e.Row.RowIndex) ;
}
}
}