Solved

ASP.NET Datagrid problem

Posted on 2003-12-01
8
661 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Log4Net custom Appender not being fired. 5 74
Icons and Colors for Terms 3 24
ASP.NET 5 Templates 2 65
Get Client IP on RDS - VB.NET 15 25
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

20 Experts available now in Live!

Get 1:1 Help Now