How to get Gridview cell value on select?

Discussion in 'ASP .Net Web Controls' started by Dave Hewes, Feb 28, 2007.

  1. Dave Hewes

    Dave Hewes Guest

    I am new to 2.0 and converting a page over from 1.1 datagrid.

    How do I do the same thing as the following in a Gridview?

    Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    DataGrid1.ItemCommand
    If e.CommandName = "Select" Then
    Server.Transfer("frmProjectView.aspx?ProID=" +
    e.Item.Cells(1).Text)
    End If
    End Sub


    Dave
     
    Dave Hewes, Feb 28, 2007
    #1
    1. Advertising

  2. Dave Hewes

    Dave Hewes Guest

    That works great...Thanks

    "David Longnecker" wrote:

    > Dave-
    >
    > Here's one option.
    >
    > On your ASPX page, your GridView will have:
    >
    > <asp:GridView ID="testGridView" runat="server" AutoGenerateColumns="False"
    > OnSelectedIndexChanged="testGridView_SelectedIndexChanged">
    > <Columns>
    > <asp:CommandField ButtonType="Button" ShowSelectButton="True" SelectText="View
    > Report" />
    > <asp:BoundField DataField="value1" />
    > <asp:BoundField DataField="value2" />
    > </Columns>
    > </asp:GridView>
    >
    > Your code-behind:
    >
    > protected void testGridView_SelectedIndexChanged(object sender, EventArgs e)
    > {
    > Server.Transfer("frmProjectView.aspx.aspx?ProId=" + testGridView.SelectedRow.Cells[1].Text);
    > }
    >
    > Good luck!
    >
    > -dl
    >
    > ---
    > David Longnecker
    > Web Developer
    > http://blog.tiredstudent.com
    >
    > > I am new to 2.0 and converting a page over from 1.1 datagrid.
    > >
    > > How do I do the same thing as the following in a Gridview?
    > >
    > > Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    > > DataGrid1.ItemCommand
    > > If e.CommandName = "Select" Then
    > > Server.Transfer("frmProjectView.aspx?ProID=" +
    > > e.Item.Cells(1).Text)
    > > End If
    > > End Sub
    > > Dave
    > >

    >
    >
    >
     
    Dave Hewes, Feb 28, 2007
    #2
    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. G. Whiz

    Gridview: Get the value in the cell

    G. Whiz, Mar 1, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,956
    Ken Cox - Microsoft MVP
    Mar 1, 2006
  2. Chris

    Get GridView Cell Value

    Chris, Apr 5, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    76,353
    imranwahabit
    Jun 14, 2009
  3. graphicsxp

    get value of a cell in a gridview

    graphicsxp, May 22, 2006, in forum: ASP .Net
    Replies:
    12
    Views:
    88,527
    brianguy16
    Feb 20, 2008
  4. Mike

    get cell value within gridview

    Mike, Oct 18, 2007, in forum: ASP .Net
    Replies:
    14
    Views:
    2,747
  5. RJ
    Replies:
    1
    Views:
    248
    Eliyahu Goldin
    Feb 17, 2005
Loading...

Share This Page