473,395 Members | 2,796 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.

Highlighting row in Gridview?

VMI
How can I select a row in a Web gridview? I added a ButtonField to my
gridview, but I'm not certain what other properties I should change in
order for the row to be highlighted. I also changed the
EditRowStyle.BackColor and EditRowStyle.BorderColor properties so that
I could see some change when I click on the button column. When I
click on the button, it does postback, but I don't see the highlighted
item.
What am I doing wrong? I'm filling the datagrid in the (!IsPostBack)
condition.

Thanks.

Sep 12 '06 #1
3 2913
"VMI" <my****@excite.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
How can I select a row in a Web gridview? I added a ButtonField to my
gridview, but I'm not certain what other properties I should change in
order for the row to be highlighted. I also changed the
EditRowStyle.BackColor and EditRowStyle.BorderColor properties so that
I could see some change when I click on the button column. When I
click on the button, it does postback, but I don't see the highlighted
item.
What am I doing wrong? I'm filling the datagrid in the (!IsPostBack)
condition.
Not sure exactly what you're trying to achieve here, but the following code
might help. Basically, you click on a row on the GridView, and it takes you
to another page passing the row ID as a QueryString.

If you need to do other things e.g. just highlight the row which was
clicked, you just need the GridView's SelectedValue and from this you can
work out which row to change the BackColor for etc...
<asp:GridView ID="gvGrid" runat="server"
OnRowDataBound="gvGrid_RowDataBound"
OnSelectedIndexChanged="gvGrid_SelectedIndexChange d">
....
....
....
</asp:GridView>

protected void gvGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(gvGrid, "Select$" +
e.Row.RowIndex.ToString()));
}
}

protected void gvGrid_SelectedIndexChanged(object sender, EventArgs e)
{
string strRecordID = gvGrid.SelectedValue.ToString();
Response.Redirect("edit.aspx?id=" + strRecordID, false);
}
Sep 12 '06 #2
VMI
Thanks for the post.

The reason i was asking is that in another web app I'm working on, the
programmer who worked on this did the same thing by (apparently) just
adding "<SelectedItemStyle BackColor="lime"></SelectedItemStyle>" to
the html. He did this with a datagrid in .net 2003 v1.1. Basically
what I want to do is highlight the row whose "ButtonColumn" I clicked
on (with the gridview and studio 2005).

Mark Rae ha escrito:
"VMI" <my****@excite.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
How can I select a row in a Web gridview? I added a ButtonField to my
gridview, but I'm not certain what other properties I should change in
order for the row to be highlighted. I also changed the
EditRowStyle.BackColor and EditRowStyle.BorderColor properties so that
I could see some change when I click on the button column. When I
click on the button, it does postback, but I don't see the highlighted
item.
What am I doing wrong? I'm filling the datagrid in the (!IsPostBack)
condition.

Not sure exactly what you're trying to achieve here, but the following code
might help. Basically, you click on a row on the GridView, and it takes you
to another page passing the row ID as a QueryString.

If you need to do other things e.g. just highlight the row which was
clicked, you just need the GridView's SelectedValue and from this you can
work out which row to change the BackColor for etc...
<asp:GridView ID="gvGrid" runat="server"
OnRowDataBound="gvGrid_RowDataBound"
OnSelectedIndexChanged="gvGrid_SelectedIndexChange d">
...
...
...
</asp:GridView>

protected void gvGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(gvGrid, "Select$" +
e.Row.RowIndex.ToString()));
}
}

protected void gvGrid_SelectedIndexChanged(object sender, EventArgs e)
{
string strRecordID = gvGrid.SelectedValue.ToString();
Response.Redirect("edit.aspx?id=" + strRecordID, false);
}
Sep 12 '06 #3
"VMI" <my****@excite.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
Basically what I want to do is highlight the row whose "ButtonColumn"
I clicked on (with the gridview and studio 2005).
So what's the problem...?
Sep 12 '06 #4

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

Similar topics

9
by: Jay Davis | last post by:
I use xemacs and syntax highlighting for my IDE, but I'm not a big fan of the default syntax highlighting colors. For instance, in 'def fun():' both 'def' and 'fun' are the same color. I kind of...
3
by: Mark | last post by:
Hi there, I have a subform, set as a continuous form. When a user selects a particular record in that subform, how can I make that particular record stand out (color or font change, size, etc) from...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
0
by: Brian Scott | last post by:
I am currently trying to control the syntax highlighting of a richtextbox control whilst the user types. At the moment I have implemented a thread which calls the richTextBox.Invoke on a method...
0
by: MasterChief | last post by:
I am trying to get it so when I go over a row in a gridview it will highlight the row. I have looked at some examples but can't get it to work. Protected Sub GridView1_RowDataBound(ByVal sender...
4
by: lord.zoltar | last post by:
I am wondering how you guys highlight cells or rows (by changing the text or background colour) in a DataGridView. Right now, I apply styles to certain rows or cells in the CellFormatting even...
2
by: rockstar_ | last post by:
Hello all- I'm developing a Content Management software for my own site, and possibly package and deploy to other sites (for friends, family, etc.) The content management software is combined...
11
by: Christoph Burschka | last post by:
Are there any free PHP libraries/utility functions that can color the syntax of various programming languages (eg. Java and C++)? I am posting code snippets on my site and would like to know if...
7
by: Leif902 | last post by:
After much searching of google, the closest I can find is highlighting search terms... however, this is not what I wanted to do. Does anyone know how to parse through a specific element (lets say...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.