Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid Buttom Column

Reply
Thread Tools

Datagrid Buttom Column

 
 
Joana
Guest
Posts: n/a
 
      03-03-2005
How do I make my ButtonColumn(In my DataGrid) to ResponseRedirect to another
aspx.page when the user click on the button. I also want send with a id for
the row.

For eksample:
************************************************** ****************

Private Sub DataGrid_kurs_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DataGrid_kurs.SelectedIndexChanged
Dim strKurs As String

strKurs = DataGrid_kurs.SelectedItem.Cells(0).Text

Response.Redirect("kurstilfelle.aspx?kurs=" + strKurs)

End Sub

******************************************

Is this the right plase to do it and how do make it work? Nothing happens
when I click on the button.

/Newbeginner


 
Reply With Quote
 
 
 
 
Grant Merwitz
Guest
Posts: n/a
 
      03-03-2005
you need to use the Datagrids built in OnItemCommand and the
DataGridCommandEventArgs in the Sub

..aspx

<aspataGrid id=DataGrid_kurs runat=server
OnItemCommand="DataGrid_kurs_OnItemCommand" AutogenerateColumns="true"/>

..vb (in the code)

public sub DataGrid_kurs_OnItemCommand(sender As System.Object, e As
System.DataGridCommandEventArgs)
string strKurs = e.Item.Cells(0).Text 'where cell 0 has the id
Response.Redirect("kurstilfelle.aspx?kurs=" + strKurs)
End Sub

Hope that clears things up


"Joana" <johanna[invalid](E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How do I make my ButtonColumn(In my DataGrid) to ResponseRedirect to
> another aspx.page when the user click on the button. I also want send
> with a id for the row.
>
> For eksample:
> ************************************************** ****************
>
> Private Sub DataGrid_kurs_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> DataGrid_kurs.SelectedIndexChanged
> Dim strKurs As String
>
> strKurs = DataGrid_kurs.SelectedItem.Cells(0).Text
>
> Response.Redirect("kurstilfelle.aspx?kurs=" + strKurs)
>
> End Sub
>
> ******************************************
>
> Is this the right plase to do it and how do make it work? Nothing happens
> when I click on the button.
>
> /Newbeginner
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?RG90TmV0SmVyb21l?=
Guest
Posts: n/a
 
      03-03-2005
Hi,

If you want to use a button column, then you 've to write the eventhadler
for the button column you crfeated, separately.

Beofre that modify your .aspx source file like this, ( You have to include
OnItemCommand ).


<aspataGrid id="DgDetails" style="Z-INDEX: 103; LEFT: 64px; POSITION:
absolute; TOP: 168px"
runat="server" Width="784px" Height="120px" BorderColor="#3366CC"
BorderWidth="1px" BackColor="White"
BorderStyle="None" CellPadding="4" OnItemCommand="DgDetails_ItemCommand">
<SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99"
BackColor="#009999"></SelectedItemStyle>
<ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#CCCCFF"
BackColor="#003399"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select" DataTextField="DNo"></asp:ButtonColumn>
</Columns>
</aspataGrid>

You have to specify the index filed in "DataTextField" of <asp:ButtonColumn>
node.

In your code behind file...create a eventhandler as follows


void DgDetails_ItemCommand(Object sender, DataGridCommandEventArgs e)
{
Response.Write(e.Item.ItemIndex.ToString());

}

e.Item.ItemIndex will have the value you need.

Cheers,

Jerome. M

"Joana" wrote:

> How do I make my ButtonColumn(In my DataGrid) to ResponseRedirect to another
> aspx.page when the user click on the button. I also want send with a id for
> the row.
>
> For eksample:
> ************************************************** ****************
>
> Private Sub DataGrid_kurs_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> DataGrid_kurs.SelectedIndexChanged
> Dim strKurs As String
>
> strKurs = DataGrid_kurs.SelectedItem.Cells(0).Text
>
> Response.Redirect("kurstilfelle.aspx?kurs=" + strKurs)
>
> End Sub
>
> ******************************************
>
> Is this the right plase to do it and how do make it work? Nothing happens
> when I click on the button.
>
> /Newbeginner
>
>
>

 
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
Need Help with a Submit buttom and textField Teresa Java 1 10-10-2006 03:58 AM
Open a formView on buttom Clicked John Carson C++ 1 04-29-2006 02:12 PM
Please help a newbie (putting a link at buttom of page) Daniel Nielsen HTML 1 04-15-2006 05:59 PM
Prevent "Back" Buttom in Browser George ASP General 6 07-07-2005 05:48 PM
Bookmark buttom in Firefox D Cheung Firefox 2 02-07-2005 03:30 AM



Advertisments