Need Help in creating a HyperlinkButton in Datagrid

Discussion in 'ASP .Net Datagrid Control' started by Faizal Tan, Feb 23, 2005.

  1. Faizal Tan

    Faizal Tan Guest

    Hi guys, i have a problem with my button in my datagrid. Wht i need to do
    is have this button link to another page. The button must also pass an ID to
    the next page. this is wht i coded in the code behind.

    Where " +e.Item.Cells[0].Text); " is pointing to an invisble Bound
    column with a Data field named i_ComponentSetupId ( tht is the id thts its
    supposed to pass to the next page).

    Hmm, it aint working. I'm new to programming, i wonder if anyone can show
    me any examples?
    Thx in advance people.
    private void DataGridComponentProcesses_ItemCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)

    {

    Response.Redirect("EditComponentSetup.aspx?id="+ e.Item.Cells[0].Text);

    }
    Faizal Tan, Feb 23, 2005
    #1
    1. Advertising

  2. Faizal Tan

    Faizal Tan Guest

    One last thing guys, How should i code it if i have another in the same grid
    linking to another page? How do i define which button is for which link?
    Thx guys.


    "Faizal Tan" <> wrote in message
    news:%23%...
    > Hi guys, i have a problem with my button in my datagrid. Wht i need to do
    > is have this button link to another page. The button must also pass an ID
    > to the next page. this is wht i coded in the code behind.
    >
    > Where " +e.Item.Cells[0].Text); " is pointing to an invisble
    > Bound column with a Data field named i_ComponentSetupId ( tht is the id
    > thts its supposed to pass to the next page).
    >
    > Hmm, it aint working. I'm new to programming, i wonder if anyone can show
    > me any examples?
    > Thx in advance people.
    > private void DataGridComponentProcesses_ItemCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    >
    > {
    >
    > Response.Redirect("EditComponentSetup.aspx?id="+ e.Item.Cells[0].Text);
    >
    > }
    >
    >
    >
    >
    >
    >
    Faizal Tan, Feb 23, 2005
    #2
    1. Advertising

  3. Faizal Tan

    Elton Wang Guest

    Hi Faizal,

    Basically

    Response.Redirect("EditComponentSetup.aspx?id="+
    e.Item.Cells[0].Text);

    is right.

    But question is the column index. You try to take a value
    from the first column. I suppose you might use the first,
    or even the second, columns as click buttons. In that
    case, you should use e.Item.Cells[2].Text (or may other,
    you should figure out).

    In order to distinguish button, you have to assign
    CommandName for each button. Then you can

    If (e.CommandName == CommandBtnOne){
    // go to page one
    return;
    }
    If (e.CommandName == CommandBtnTwo){
    // go to page two
    return;
    }

    HTH

    Elton Wang




    >-----Original Message-----
    >One last thing guys, How should i code it if i have

    another in the same grid
    >linking to another page? How do i define which button is

    for which link?
    >Thx guys.
    >
    >
    >"Faizal Tan" <> wrote in

    message
    >news:%23%...
    >> Hi guys, i have a problem with my button in my

    datagrid. Wht i need to do
    >> is have this button link to another page. The button

    must also pass an ID
    >> to the next page. this is wht i coded in the code

    behind.
    >>
    >> Where " +e.Item.Cells[0].Text); " is pointing

    to an invisble
    >> Bound column with a Data field named

    i_ComponentSetupId ( tht is the id
    >> thts its supposed to pass to the next page).
    >>
    >> Hmm, it aint working. I'm new to programming, i wonder

    if anyone can show
    >> me any examples?
    >> Thx in advance people.
    >> private void DataGridComponentProcesses_ItemCommand

    (object source,
    >> System.Web.UI.WebControls.DataGridCommandEventArgs e)
    >>
    >> {
    >>
    >> Response.Redirect("EditComponentSetup.aspx?id="+

    e.Item.Cells[0].Text);
    >>
    >> }
    >>
    >>
    >>
    >>
    >>
    >>

    >
    >
    >.
    >
    Elton Wang, Feb 23, 2005
    #3
  4. Faizal Tan

    Faizal Tan Guest

    Thx Elton, tht worked and I found out actually tht in the property box of
    the grid, it actually didn't connect to the item command tht I double
    clicked in the first place. I merely select it back again and it worked. Thx
    for your help and have a great day!

    "Faizal Tan" <> wrote in message
    news:%23%...
    > Hi guys, i have a problem with my button in my datagrid. Wht i need to do
    > is have this button link to another page. The button must also pass an ID
    > to the next page. this is wht i coded in the code behind.
    >
    > Where " +e.Item.Cells[0].Text); " is pointing to an invisble
    > Bound column with a Data field named i_ComponentSetupId ( tht is the id
    > thts its supposed to pass to the next page).
    >
    > Hmm, it aint working. I'm new to programming, i wonder if anyone can show
    > me any examples?
    > Thx in advance people.
    > private void DataGridComponentProcesses_ItemCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    >
    > {
    >
    > Response.Redirect("EditComponentSetup.aspx?id="+ e.Item.Cells[0].Text);
    >
    > }
    >
    >
    >
    >
    >
    >
    Faizal Tan, Feb 24, 2005
    #4
    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. Chetna Joshi
    Replies:
    0
    Views:
    494
    Chetna Joshi
    Jul 5, 2003
  2. soni29
    Replies:
    0
    Views:
    337
    soni29
    Nov 30, 2003
  3. TN Bella
    Replies:
    1
    Views:
    2,453
    Edward
    Jun 18, 2004
  4. Jie
    Replies:
    1
    Views:
    444
    =?Utf-8?B?SWFuIFN1dHRsZQ==?=
    Nov 13, 2004
  5. =?Utf-8?B?Sm9l?=

    Need help with creating a calendar of events

    =?Utf-8?B?Sm9l?=, Jan 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,642
    Scott Allen
    Jan 11, 2005
Loading...

Share This Page