473,395 Members | 1,675 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,395 software developers and data experts.

GridView selectedrow values

Hello,

my problem: i want to get the values of the selected rows of a
GridView.
I have a button in every row and want to get the actual values e.g. of
cell 1 of the actual row.

How can i get this value?
I am using VS 2005 and VB.
Thanks a lot!

Best regards
Benjamin

Oct 17 '06 #1
3 10231
"HaVoK" <ha**********@googlemail.comwrote in message
news:11********************@i3g2000cwc.googlegroup s.com...
my problem: i want to get the values of the selected rows of a
GridView.
No problem.
I have a button in every row
You don't actually need a button to select a row - just clicking on it
selects it...
and want to get the actual values e.g. of cell 1 of the actual row.

How can i get this value?
I am using VS 2005 and VB.
The following code is in C#, but it should guide you through the process..

<asp:GridView ID="MyGridView" runat="server"
OnRowDataBound="MyGridView_RowDataBound"
OnSelectedIndexChanged="MyGridView_SelectedIndexCh anged">

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(MyGridView, "Select$" +
e.Row.RowIndex.ToString()));
e.Row.Style["cursor"] = "pointer";
}
}

protected void MyGridView_SelectedIndexChanged(object sender, EventArgs e)
{
string strFirstCell = MyGridView.SelectedRow.Cells[0].Text;
}
Oct 17 '06 #2
thanks a lot :-) now it's working fine.
--for me it was a problem;-) I am unfortunately a beginner...

Best regards
Benjamin
Mark Rae schrieb:
"HaVoK" <ha**********@googlemail.comwrote in message
news:11********************@i3g2000cwc.googlegroup s.com...
my problem: i want to get the values of the selected rows of a
GridView.

No problem.
I have a button in every row

You don't actually need a button to select a row - just clicking on it
selects it...
and want to get the actual values e.g. of cell 1 of the actual row.

How can i get this value?
I am using VS 2005 and VB.

The following code is in C#, but it should guide you through the process..

<asp:GridView ID="MyGridView" runat="server"
OnRowDataBound="MyGridView_RowDataBound"
OnSelectedIndexChanged="MyGridView_SelectedIndexCh anged">

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(MyGridView, "Select$" +
e.Row.RowIndex.ToString()));
e.Row.Style["cursor"] = "pointer";
}
}

protected void MyGridView_SelectedIndexChanged(object sender, EventArgs e)
{
string strFirstCell = MyGridView.SelectedRow.Cells[0].Text;
}
Oct 17 '06 #3
"HaVoK" <ha**********@googlemail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
thanks a lot :-) now it's working fine.
Welcome.
--for me it was a problem;-) I am unfortunately a beginner...
We were all beginners once...
Oct 17 '06 #4

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

Similar topics

3
by: mosscliffe | last post by:
I have a gridview and in the GridView1_SelectedIndexChanged routine I am attempting to get at the data in the row I have done it successfully with cells 'Access the contents of a field in a...
3
by: Gunawan | last post by:
Dear All, I have data which display on the GridView. GridView contain 3 Column (ProductId, ProductCode and Description). I would like to display only Product Code and Description so I hide...
1
by: jobs | last post by:
Given the Gridview below: When I select the button "Rate" and fall into this code. How can I reference "carriercode" and others . Apparently selecting the button does not select the row. I've...
7
by: Badis | last post by:
Hi, I've a radiobutton in my gridview and I want to dislpay the value in a cell of the selected value on the RadioButton click using this code : TextBox.Text =...
1
by: moni | last post by:
Hi, I was hoping to know how I could get the text value of a gridview row. My code is this way: <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"...
14
by: Mike | last post by:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on. So if my gridview looks like this: N-12 BMW ...
0
by: Moneypenny | last post by:
Hi there, I have a Gridview control which has a dropdownlist in every row. The dropdowns are populated dynamically from a database (so the content is different in each row. There is also a select...
7
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all, this is a second post, so apologies, but I never had an answer to my first post (several weeks ago) and I really need some help. I'm using a .Net 2.0 Gridview which is populated using an...
0
by: edurazee | last post by:
I am able to create BoundFields and Footer-rows dynamically like this in my GridView: protected void Page_Load(object sender, EventArgs e) { CreateGridView(); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.