Need Help in creating a HyperlinkButton in Datagrid

F

Faizal Tan

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

}
 
F

Faizal Tan

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

Elton Wang

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
(e-mail address removed)


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


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

}


.
 
F

Faizal Tan

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top