Solved

ASP.NET Datagrid problem

Posted on 2003-12-01
8
694 Views
Last Modified: 2007-12-19
Having a problem using the Datagrid editing functions (ASP.NET)

Basically, i'm using the following code to update the datasource with the inbuilt editing functionality of the datagrid.
(function for on_Update)

ds = (DataSet)Session["Source"];
DataRow row;
row = ds.Tables[0].Rows.Find(dgRejectGrid.DataKeys[e.Item.ItemIndex]);

int UserTimeID = int.Parse(row.ItemArray[0].ToString());
TextBox RejectNotes = (TextBox)e.Item.Cells[2].Controls[1];

string str = RejectNotes.Text;

Basically the control is found that isn't the problem, the only problem is the RejectNotes.Text always returns as empty string "".
I'm using the exact same code somewhere and it works fine!  
I've setup the textbox correctly with the correct databindings.
DataBinder.Eval(Container, "DataItem.AuthRejectText")

I've deleted the datagrid and started again but i get the same problem.

Any ideas?
0
Comment
Question by:xloop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
ID: 9849512
what exactly returns  (TextBox)e.Item.Cells[2].Controls[1] ?
does ((TextBox)e.Item.Cells[2].Controls[1] ).Text is also empty?
if it is try this

TextBox RejectNotes = (TextBox)e.Item.Cells[2].FindControls("yourtextboxid");

B..G
0
 
LVL 1

Author Comment

by:xloop
ID: 9849536
(TextBox)e.Item.Cells[2].Controls[1]   returns  'Textbox'

and yes ((TextBox)e.Item.Cells[2].Controls[1] ).Text  returns an empty string

the last suggestion i've also tried which doesn't work.  

Don't understand...
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 9849550
can you post the code you use in your html

may be you can try to use this
DataBinder.Eval(Container.DataItem, "AuthRejectText") ( if AuthRejectText is your field's name )

B..G
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 1

Author Comment

by:xloop
ID: 9849817
What should i use as the first param of DataBinder.Eval?  

C:\Inetpub\wwwroot\TimeManagement\RejectTime.aspx.cs(109): 'System.ComponentModel.Container' does not contain a definition for 'DataItem'
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 9849837
When do you receive this error? when you type
this :
<%# DataBinder.Eval(Container.DataItem,"AuthRejectText") %>

or this :
<%# DataBinder.Eval(Container,"DataItem.AuthRejectText") %>
??

B..G

0
 
LVL 1

Author Comment

by:xloop
ID: 9850683
The first one errors the second one doesn't error but returns empty string.

0
 
LVL 28

Expert Comment

by:mmarinov
ID: 9850763
can you post the code to see where the problem is ?

B..G
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 9850796
By the way look you use <%# DataBinder.Eval(Container.DataItem,"AuthRejectText") %> in the template of the current column. Other way you don't have DataItem object

B..G

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question