Home All Groups Group Topic Archive Search About

Need Help in creating a HyperlinkButton in Datagrid

Author
23 Feb 2005 6:28 AM
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);

}

Author
23 Feb 2005 7:00 AM
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.


Show quoteHide quote
"Faizal Tan" <fai***@crimsonworks.com.sg> wrote in message
news:%23%23Cu6FXGFHA.392@TK2MSFTNGP14.phx.gbl...
> 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);
>
> }
>
>
>
>
>
>
Author
23 Feb 2005 1:47 PM
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
elton_w***@hotmail.com



>-----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" <fai***@crimsonworks.com.sg> wrote in
message
>news:%23%23Cu6FXGFHA.392@TK2MSFTNGP14.phx.gbl...
>> 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);
Show quoteHide quote
>>
>> }
>>
>>
>>
>>
>>
>>
>
>
>.
>
Author
24 Feb 2005 1:18 AM
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!

Show quoteHide quote
"Faizal Tan" <fai***@crimsonworks.com.sg> wrote in message
news:%23%23Cu6FXGFHA.392@TK2MSFTNGP14.phx.gbl...
> 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);
>
> }
>
>
>
>
>
>