how to invoke an event

Posted by Dotnetmatrix under ASP.NET on 5/8/2010 | Views : 2934 | Status : [Member] | Replies : 3
hi folks,

how to invoke an event when i click button. Let me explain in details.. I've a Gridview and button*(button is outside the gridview) when I click the button I want to call RowDataBound event on button click.

I tried this but its not working....
protected void Button1_Click(object sender, EventArgs e)
{

GridView1.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound);
}
void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
FillGrid();
if (e.Row.RowType == DataControlRowType.DataRow)
{
int i = (int)DataBinder.Eval(e.Row.DataItem, "UnitsOnOrders");
if (i > 15)
{
e.Row.BackColor = Color.Magenta;
e.Row.ForeColor = Color.Wheat;
}
}
}




Responses

Posted by: Abhi2434 on: 5/8/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Then you should call it directly.

protected void Button1_Click(object sender, EventArgs e)

{

GridView1_RowDataBound(this.GridView1, GridViewRowEventArgs.Empty);
}


I think this would work.

www.abhisheksur.com

Dotnetmatrix, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Er.deepakdalal on: 5/9/2010 [Member] Starter

Up
0
Down
try this one:-


protected void Button1_Click(object sender, EventArgs e)

{
GridView1_RowDataBound(sender, e);
}

Dotnetmatrix, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 5/10/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Dear Er.deepakdalal

Repeating the same answer again to increase post count is not always good.

www.abhisheksur.com

Dotnetmatrix, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response