473,657 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding the current row in a DataGrid to edit

I'm having a problem updating a DataGrid when using the
grid's in-place editing features. I believe that my major
problem is locating the row in the dataset that matches
the row in the grid. Does anyone have any ideas how I
might do this, or where I can look to for a good resource,
as I haven't found anything on MSDN or some of my other
favorites that address this. The latest code that I've
tried is listed below.

Thanks,
Jeff
private void DataGrid1_Updat eCommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string strDate = ((TextBox)(e.It em.Cells
[3].Controls[0])).Text;
string strException = ((TextBox)(e.It em.Cells
[4].Controls[0])).Text;
string strDuration = ((TextBox)(e.It em.Cells
[5].Controls[0])).Text;
string strCount = ((TextBox)(e.It em.Cells
[0].Controls[0])).Text;
foreach (DataGridItem di in DataGrid1.Items )
{
if ( di.ItemIndex.To String() == strCount)
{
//get current row
DataRow dr = ds.Tables
["exceptions "].Rows.Find (DataGrid1.Data Keys
[di.ItemIndex]);
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.WriteXml (Server.MapPath
(Request.Applic ationPath) + "\\exceptions.x ml");
DataGrid1.DataB ind();
}
}
}
Nov 17 '05 #1
0 943

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

Similar topics

5
1301
by: Steven C | last post by:
Hello: I have a datagrid that has a dataset bound to it. When the customer selects a certain row in the grid, I would like to be able to grab the PK for that row, so I can call the customer edit form and load the textboxes with a SELECT based upon that PK. How do I do this? In Foxpro, since cursors have global scope, I would just call the edit form and load the textboxes from the current (selected) record. Thanks!
2
1721
by: VMI | last post by:
Hi, I have a Windows datagrid that's attached to a filled datatable. The grid also has a tablestyle. Since the data from the grid comes from a datatatable, how can I retrieve the data from a specific table row once a user clicks on a grid row? I already have the code that lets me know what grid row the user clicked on, but, for example, if I want to retrieve the value of the 5th column in the grid, I'm currently using myGrid.ToString()....
3
2124
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do this: SomeRow = 'value'; But how do I set SomeRow to the row that the user is currently viewing?
2
2325
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last, Fax, Phone, Category). Put an Edit column at the end... Now what?! If you go into Edit mode -- you can only edit 5 cells -- not all the rest of the Record's fields...not enough!
0
473
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass = "SectionTableLines"; dgG.DataKeyField = "PlanWorkOrderID";
12
1996
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the conversion is extremely costly in performance. Does anybody know how I could set the label (of the whole content of the TableCell) to .Visible = False without converting e.Item.Controls(2) to a System.Web.UI.WebControls.Label?
9
4600
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be consistant. Thanks, Tom.
2
2014
by: jason | last post by:
Pardon my ignorance on this. The below code works, except, when I edit a record and update the two drop downs take the first entry in the dropdownlist if not selected. I'd also like the dropdown to show the current value in edit mode. I'm sure this is a common question. I've reviewed several related post and tried them out to no avial. Some of the offerings in listgroup look right on, but are not clear on where to handle the suggested...
1
13301
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit ImageButton I needed to redirect the user to the Edit page where the data on the page would be prepopulated with data from the database. I tried several things without success then discovered that the CommandArgument property could be used for this...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
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
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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...
0
8606
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
7337
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
5632
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();...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
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

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.