473,385 Members | 1,474 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.

DataGrid - Edit Command

Hello, I can not seem to get my "EditCommand" event to fire. My code for the
datagrid looks like the following:

<asp:datagrid id="dgTask" runat="server" PagerStyle-Mode="NextPrev"
ShowFooter="True" PageSize="25"
OnPageIndexChanged="dgTask_PageChangeRequested"
PagerStyle-HorizontalAlign="Right" PagerStyle-CssClass="text12Bold"
PagerStyle-NextPageText="Next" PagerStyle-PrevPageText="Previous"
CellSpacing="2" BorderWidth="1px"
CellPadding="3" BackColor="#DEBA84" BorderStyle="None"
BorderColor="#DEBA84" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
OnSortCommand="dgTask_SortCommand" OnEditCommand="dgTask_EditCommand">
<FooterStyle Font-Size="10px" ForeColor="#8C4510"
BackColor="#F7DFB5"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle Font-Size="10px" ForeColor="#8C4510"
BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Size="10px" Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
......
</asp:datagrid>

My method looks like the following...

public void dgTask_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "EditTask")
{
int itemOffSet = 0;
if (dgTask.CurrentPageIndex > 0)
{ itemOffSet = dgTask.CurrentPageIndex * dgTask.PageSize; }
_EditRowID = (e.Item.ItemIndex + itemOffSet);
if (ViewState["EditRowID"] == null)
{ ViewState.Add("EditRowID", _EditRowID); }
else
{ ViewState["EditRowID"] = _EditRowID; }
dgTask_Edit_Command(_DvTask[_EditRowID].Row);
}
}

If I code the On_ItemCommand Event - that event fires and I can direct it to
the method identified above. Shoule it not just go directly to the method
above?

Thanks in advance for your assistance!!!

Nov 19 '05 #1
2 1504
I think it would help if you boiled the sample code down to the bare basics,
and then included the complete sample code. So remove all formatting,
sorting etc, and try to post a real simple sample that - of course - doesn't
work when you click the edit column.

Jeppe Jespersen


"Jim Heavey" <Ji*******@discussions.microsoft.com> skrev i en meddelelse
news:30**********************************@microsof t.com...
Hello, I can not seem to get my "EditCommand" event to fire. My code for
the
datagrid looks like the following:

<asp:datagrid id="dgTask" runat="server" PagerStyle-Mode="NextPrev"
ShowFooter="True" PageSize="25"
OnPageIndexChanged="dgTask_PageChangeRequested"
PagerStyle-HorizontalAlign="Right" PagerStyle-CssClass="text12Bold"
PagerStyle-NextPageText="Next" PagerStyle-PrevPageText="Previous"
CellSpacing="2" BorderWidth="1px"
CellPadding="3" BackColor="#DEBA84" BorderStyle="None"
BorderColor="#DEBA84" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
OnSortCommand="dgTask_SortCommand" OnEditCommand="dgTask_EditCommand">
<FooterStyle Font-Size="10px" ForeColor="#8C4510"
BackColor="#F7DFB5"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle Font-Size="10px" ForeColor="#8C4510"
BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Size="10px" Font-Bold="True" ForeColor="White"
BackColor="#A55129"></HeaderStyle>
.....
</asp:datagrid>

My method looks like the following...

public void dgTask_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "EditTask")
{
int itemOffSet = 0;
if (dgTask.CurrentPageIndex > 0)
{ itemOffSet = dgTask.CurrentPageIndex * dgTask.PageSize; }
_EditRowID = (e.Item.ItemIndex + itemOffSet);
if (ViewState["EditRowID"] == null)
{ ViewState.Add("EditRowID", _EditRowID); }
else
{ ViewState["EditRowID"] = _EditRowID; }
dgTask_Edit_Command(_DvTask[_EditRowID].Row);
}
}

If I code the On_ItemCommand Event - that event fires and I can direct it
to
the method identified above. Shoule it not just go directly to the method
above?

Thanks in advance for your assistance!!!

Nov 19 '05 #2
I wonder if it has to do with AutoEventWireup ?
http://support.microsoft.com/?kbid=324151

Nov 19 '05 #3

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

Similar topics

0
by: NETDeveloper | last post by:
Hi, I almost have my nested datagrid working properly. I created a datagrid on a user control and dropped that onto another datagrid. At first, I noticed when I was stepping through the code,...
4
by: Stephen | last post by:
I have got an event below to remove items from an arraylist and then to rebind the arraylist to the datagrid subsequently deleting the appropriate row. My problem is that my code makes sense and I...
0
by: Wayneb | last post by:
Hi I have a datagrid with autogenerates columns based upon a dataset I have constructed from the results of database query - pretty noddy stuff. When you click on Edit I remove the standard...
0
by: San Diego Guy | last post by:
Hi all! I have Datagrid. Within that datagrid I have a drop down list that I set up some values in (a "collection") I set up an edit command column on the datagrid and wrote simple code to get...
0
by: Linus | last post by:
Hi, I have a datagrid nested inside another datagrid, the edit/update/cancel command works fine on the outter datagrid but I'm having problems with the inner one. There are 2 problems and here's...
1
by: Dan | last post by:
Hi all, I have a question about datagrid: let's say I have a datagrid which shows the categories for some items; each category has an ID field and a description. I use an ASP.NET page with a...
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...
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...
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...
1
by: Andrew Wan | last post by:
Is it possible to make some of the DataGrid functionality to client-side? Such as the Edit, Update, Cancel, Delete functionality? Everytime I click on a row's Edit button, I wait 2 seconds...
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.