473,836 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ba ckColor and EditRowStyle.Bo rderColor 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 2926
"VMI" <my****@excite. comwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.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.Ba ckColor and EditRowStyle.Bo rderColor 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_RowData Bound"
OnSelectedIndex Changed="gvGrid _SelectedIndexC hanged">
....
....
....
</asp:GridView>

protected void gvGrid_RowDataB ound(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Attribute s.Add("onclick" ,
ClientScript.Ge tPostBackEventR eference(gvGrid , "Select$" +
e.Row.RowIndex. ToString()));
}
}

protected void gvGrid_Selected IndexChanged(ob ject sender, EventArgs e)
{
string strRecordID = gvGrid.Selected Value.ToString( );
Response.Redire ct("edit.aspx?i d=" + 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 "<SelectedItemS tyle BackColor="lime "></SelectedItemSty le>" 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 "ButtonColu mn" I clicked
on (with the gridview and studio 2005).

Mark Rae ha escrito:
"VMI" <my****@excite. comwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.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.Ba ckColor and EditRowStyle.Bo rderColor 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_RowData Bound"
OnSelectedIndex Changed="gvGrid _SelectedIndexC hanged">
...
...
...
</asp:GridView>

protected void gvGrid_RowDataB ound(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Attribute s.Add("onclick" ,
ClientScript.Ge tPostBackEventR eference(gvGrid , "Select$" +
e.Row.RowIndex. ToString()));
}
}

protected void gvGrid_Selected IndexChanged(ob ject sender, EventArgs e)
{
string strRecordID = gvGrid.Selected Value.ToString( );
Response.Redire ct("edit.aspx?i d=" + strRecordID, false);
}
Sep 12 '06 #3
"VMI" <my****@excite. comwrote in message
news:11******** *************@p 79g2000cwp.goog legroups.com...
Basically what I want to do is highlight the row whose "ButtonColu mn"
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
4325
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 like the vim colors, but what would be really useful is to find various examples of highlighting that people have used, to see which ones just look right. I looked through google groups but didn't find any source of highlighting examples. Is...
3
7929
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 the other records in the list? Thank you in advance, Mark
4
7631
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 highlighting in C# but I have yet to find anything useful I know there are people at MS that know this stuff like the front of their hand and I know there are many people out on the web that are proficient in doing this as well but it seems nobody...
0
1668
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 that parses each line of the richTextBox and highlights specific words with a given color. I have been highlighting each of the words by using the Select method and changing the selection color beforehand. This works fine until the contents of the...
0
2139
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 As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If (e.Row.RowType = DataControlRowType.DataRow) Then e.Row.Attributes.Add("onmouseover", "this.style.backgroundcolor='blue'")
4
6108
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 handler, but the way it works is by looping through all of the rows and then deciding if that rows needs special formatting. The problem is that I don't think this method will scale well. I have a dataset with 5,000 rows (and others are larger, this...
2
2629
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 blog, photo, and site management tools. One the of the tools I would find INREDIBLY helpful is the ability to block out and syntax highlight code. I would like to be able to, as I'm writing a blog post about something I've done in Python (for...
11
2304
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 there is a way to easily give them syntax highlighting automatically. Thanks! -- Christoph Burschka <christoph.burschka@rwth-aachen.de>
7
2341
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 the innerHTML of a div) and add tags to change the styles of several keywords? For instance, I might want the words "and", "or" and "xor" to be bold and the words "c_white", "c_red" and "c_orange" to appear as maroon... (it's for a syntax...
0
9656
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10526
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10570
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10240
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6972
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3100
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.