views:

641

answers:

1

I am instantiating/using the gridview only programmatically ie code behind only.

Also, the grid is bound to a datasource, and I am only showing select columns from it by hooking rowdatabound event of the gridview.

Please suggest a way for doing it WITHOUT design view(aspx).

EDIT: Is there any way to do this using UpdatePanels?

A: 

Try this one --> http://www.netomatix.com/development/gridviewrowselectedevent.aspx

solairaja
The gridviews SelectButton generates similar javascript which does a full postback(page refresh), which is what I want to avoid
Sloane
try using the update panel to avoid postbacks
solairaja
apparently the Update Panel can only handle the server side code but not the javascript with forces a postback
Sloane
Nope you can add your own javascript in the update panel also.
solairaja
can you please elaborate.. how do I prevent the postback.. the following javacript (autogenerated for gridivew) on the page forces the postback.function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); }}Please let me know
Sloane
1. Create on AJAXEnabled Website using VS2005.2. Add a gridView with the SQLDataSource to display few records.3. Enable the "Select" in the Gridview.4. Try run the page and see the output.5. Now ur having the Gridview with "select" option, without any postbacks. 6. RowSelecting instead of particularly clicking on the "Select" link of the gridview.
solairaja
protected void PeopleGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';"; e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';"; e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.PeopleGridView, "Select$" + e.Row.RowIndex); } }
solairaja
try the above code on the gridview rowdatabound event. so that there wont be any postback. because u have updatepanel to maintain that as said before.
solairaja