Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Need Help in creating a HyperlinkButton in Datagrid

Reply
Thread Tools

Need Help in creating a HyperlinkButton in Datagrid

 
 
Faizal Tan
Guest
Posts: n/a
 
      02-23-2005
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);

}






 
Reply With Quote
 
 
 
 
Faizal Tan
Guest
Posts: n/a
 
      02-23-2005
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" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
> 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);
>
> }
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      02-23-2005
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
http://www.velocityreviews.com/forums/(E-Mail 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.
>
>
>"Faizal Tan" <(E-Mail Removed)> wrote in

message
>news:%23%(E-Mail Removed).. .
>> 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);
>>
>> }
>>
>>
>>
>>
>>
>>

>
>
>.
>

 
Reply With Quote
 
Faizal Tan
Guest
Posts: n/a
 
      02-24-2005
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" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
> 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);
>
> }
>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM
Need to create Hieararical DataGrid using ASP.Net Datagrid !!! Phani ASP .Net Datagrid Control 2 04-25-2005 12:08 PM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM
Programmatically creating a datagrid control - Events NOT Firing!!!! Please Help KJ ASP .Net Datagrid Control 0 08-11-2003 05:20 PM



Advertisments