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

Firing a DataGrid's Edit event when a row is clicked

Guys,

Apologies for asking this, but it's late and I'm clearly missing something
fairly obvious...

I have an <asp:DataGrid > control defined thus:

<asp:DataGrid ID=dgrdResults Runat=server
OnEditCommand="dgrdResults_Edit"
OnPageIndexChanged="dgrdResults_PageIndexChanged"
OnSortCommand="dgrdResults_Sort" OnItemDataBound="dgrdResults_ItemDataBound"
AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true"
PageSize="10" PagerStyle-NextPageText="Next >" PagerStyle-PrevPageText="<
Previous" PagerStyle-HorizontalAlign="Left" PagerStyle-Mode="NumericPages"
HorizontalAlign="Left" DataKeyField="intBusinessIDcnt"
PagerStyle-Font-Size="8" CellPadding="3" BorderWidth="1px"
BorderStyle="Solid">
<HeaderStyle Font-Bold="True" BackColor="#e5e5e5" Font-Name="Verdana"
ForeColor=Black Font-Size="XX-Small" Font-Underline="false"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="intBusinessIDcnt" Visible=False />
<asp:ButtonColumn CommandName="Edit" DataTextField="strBusiness"
HeaderText="Name" SortExpression="strBusiness" ItemStyle-Wrap="False"
HeaderStyle-Wrap="false" />
<asp:BoundColumn DataField="intProjects" HeaderText="Projects"
SortExpression="intProjects" ItemStyle-Wrap="False" HeaderStyle-Wrap="false"
ItemStyle-HorizontalAlign="Right"/>
</Columns>
<ItemStyle Font-Name="Verdana" Font-Size="XX-Small" />
<AlternatingItemStyle BackColor="WhiteSmoke" />
<FooterStyle ForeColor="Black" BackColor="#CCCC99" Font-Size="XX-Small"
Font-Name="Verdana"></FooterStyle>
<PagerStyle HorizontalAlign="Left" ForeColor="Black"
BackColor="White"></PagerStyle>
</asp:DataGrid>

I'm trying to make its OnEditCommand event fire when a row is clicked. I
know I've done this before, but I can't get it to work tonight...

The dgrdResults_ItemDataBound() method is as follows:

public void dgrdResults_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white'");
}
if(e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='WhiteSmoke'");
}
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='LemonChiffon'");
e.Item.Style["cursor"] = "hand";
e.Item.Attributes["onclick"] =
Page.GetPostBackEventReference(Page.FindControl("d grdResults"),
"OnEditCommand");
}
}

When I click a row, the page posts back, but doesn't fire the
dgrdResults_Edit event...

Help!

Any assistance gratefully received.

Mark
Nov 19 '05 #1
1 1245
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
Apologies for asking this, but it's late and I'm clearly missing something
fairly obvious...


As anticipated, I looked at this again first thing this morning, went
"D'oh!", and fixed it straightaway.

Sorry for the wasted bandwidth.
Nov 19 '05 #2

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

Similar topics

0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
1
by: Peter Rilling | last post by:
I have an interesting problem with a datagrid. It is the standard chicken-and-the-egg problem. I have this page with two datagrids. It essentially defines a parent-child relationship. The...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
2
by: David | last post by:
Hi all, I am dynamically creating a LinkButton in my datagrid, however, the event that I am creating for it is not firing. I am obviously missing something? What am I missing? Here is the...
2
by: Deepesh | last post by:
Good day, I have a specific case of the DataGrid in my solution which is causing the ItemCommand Event Not Firing. So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX file...
1
by: Jason Barnett | last post by:
I dropped a DataGrid control onto a Web UserControl (.ascx) and added columns for Editing and Deleting data. At first, I had everything working; when the edit button was clicked the row entered...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
0
by: arlie_maija | last post by:
Hey - I'm writing a control that contains a DataGrid, and I'm unable to get the update event to fire. When I click the update link, the edit event fires. heres the details... my control...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
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...

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.