Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

how to select a row in gridview in asp.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dinu - 01 Aug 2007 12:43 GMT
hi

how can we select a row in a gridview with out select column and get
events fired

thanks
Mark Rae [MVP] - 01 Aug 2007 13:20 GMT
> how can we select a row in a gridview with out select column and get
> events fired

<asp:GridView ID="MyGridView" runat="server"
OnRowDataBound="MyGridView_RowDataBound"
OnSelectedIndexChanged="MyGridView_SelectedIndexChanged">
...
...
...
</asp:GridView>

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
       e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(MyGridView, "Select$" +
e.Row.RowIndex.ToString()));
       e.Row.Style.Add("cursor", "pointer");
   }
}

protected void MyGridView_SelectedIndexChanged(object sender, EventArgs e)
{
   string strSelectedID = MyGridView.SelectedValue.ToString();
}

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Dinu - 01 Aug 2007 16:12 GMT
> > how can we select a row in a gridview with out select column and get
> > events fired
[quoted text clipped - 29 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

It is not working, the page got hanged (i am using vb.net as code-
behind)

Protected Sub gvwServices_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
gvwServices.RowDataBound
       If e.Row.RowType = DataControlRowType.DataRow Then
           e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(gvwServices, "Select$" +
e.Row.RowIndex.ToString()))
           e.Row.Style.Add("cursor", "pointer")
End If
End Sub
Mark Rae [MVP] - 01 Aug 2007 16:20 GMT
> It is not working, the page got hanged

On which line does the code hang...?

> (i am using vb.net as code-behind)

That certainly shouldn't make any difference...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Dinu - 02 Aug 2007 07:21 GMT
> > It is not working, the page got hanged
>
[quoted text clipped - 7 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

hi

my page has huge amount of data nearly(12500 records to be fetched
from database) and so it is hanged........if i use paging its working.

Thanks
Mark Rae [MVP] - 02 Aug 2007 07:31 GMT
> my page has huge amount of data nearly(12500 records to be fetched
> from database) and so it is hanged........if i use paging its working.

Sorted then... :-)

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.