Antarr Byrd
Antarr Byrd

Reputation: 26169

Ajax Help Involving Webgrids

I'm unexperienced with Ajax. I'm using a webgrid that executes:

javascript:__doPostBack('GridView1','Select$1')

when a row is selected. How can I call some action when this is posted?

____UPDATE_______

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.DataItemIndex == -1)
        return;

    e.Row.Attributes.Add("onMouseOver",
          "this.style.cursor='hand';");
    e.Row.Attributes.Add("onclick",
          GetPostBackClientEvent(GridView1,
          "Select$" + e.Row.RowIndex.ToString())
          );
}

Upvotes: 0

Views: 173

Answers (1)

Icarus
Icarus

Reputation: 63970

The code you wrote is not Ajax (unless the grid is enclosed in an update panel or something like that).

The way you trigger an event on the server side would be like this:

if (Request.Form["__EVENTTARGET"] == "GridView1")
{
    //fire event
    string argument = Request.Form["__EVENTARGUEMENT"];
    //do something.
}

UPDATE The important thing is going to be the "argument" piece in my code since it will have the row that the person clicked on in the form of Select$<RowNumber>

I guess you need to do something with that information.

Upvotes: 2

Related Questions