how to select a row in gridview in asp.net

Discussion in 'ASP .Net' started by Dinu, Aug 1, 2007.

  1. Dinu

    Dinu Guest

    hi

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

    thanks
    Dinu, Aug 1, 2007
    #1
    1. Advertising

  2. "Dinu" <> wrote in message
    news:...

    > 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();
    }


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Aug 1, 2007
    #2
    1. Advertising

  3. Dinu

    Dinu Guest

    On Aug 1, 5:20 pm, "Mark Rae [MVP]" <> wrote:
    > "Dinu" <> wrote in message
    >
    > news:...
    >
    > > 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();
    >
    > }
    >
    > --
    > 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
    Dinu, Aug 1, 2007
    #3
  4. "Dinu" <> wrote in message
    news:...

    > 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...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Aug 1, 2007
    #4
  5. Dinu

    Dinu Guest

    On Aug 1, 8:20 pm, "Mark Rae [MVP]" <> wrote:
    > "Dinu" <> wrote in message
    >
    > news:...
    >
    > > 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...
    >
    > --
    > 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
    Dinu, Aug 2, 2007
    #5
  6. "Dinu" <> wrote in message
    news:...

    > 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... :)


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Aug 2, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fernando Lopes
    Replies:
    0
    Views:
    3,181
    Fernando Lopes
    Apr 28, 2005
  2. misiek
    Replies:
    0
    Views:
    2,265
    misiek
    Feb 20, 2006
  3. =?Utf-8?B?RGFiYmxlcg==?=

    select gridview row without using select button?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    101,493
    dch31969
    Feb 27, 2009
  4. H5N1
    Replies:
    0
    Views:
    2,698
  5. Replies:
    5
    Views:
    646
Loading...

Share This Page