473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Datagrid Buttom Column

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 :)
Nov 19 '05 #1
2 1165
you need to use the Datagrids built in OnItemCommand and the
DataGridCommandEventArgs in the Sub

..aspx

<asp:DataGrid 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]ny****@netscape.net> wrote in message
news:38*************@individual.net...
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 :)

Nov 19 '05 #2
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 ).
<asp:DataGrid 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>
</asp:DataGrid>

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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is...
2
by: Marlene A. Roman | last post by:
Hello I have a question: I have a datagrid. I can make a specific search using some parameters I write and When a press a command button it calls an sp and returns the results of a search that...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
4
by: Anthony | last post by:
Hi Folks, I'm adding some columns to my datagrid which are of Combo Box type. I'm inheriting DataGridTextBoxColumn and doing all the usual stuff to get them populated. This is working fine. I...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
1
by: chandrasekhar | last post by:
hi, how can i populate data from one page having datagrid with check boxes in it, i should select checkboxes from data grid and click on the submit buttom , then data should be trasfered from this...
2
by: neoret | last post by:
Hello. I need some help on how to add a radiobutton to every row in the first column in a datagrid. The datasource to the datagrid is a dataTable. I loop through this table to add rows and...
0
by: ChuckMac | last post by:
I have text fields with a matching search button, that get search information keyed in a field then the search button (for that text item) is pressed which caused a database search to take place. The...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.