Solved

ASP.NET Datagrid problem

Posted on 2003-12-01
8
646 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
  • 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now