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
Solved

ASP.NET Datagrid problem

Posted on 2003-12-01
8
683 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do you do a one to many list in .NET CORE? 2 36
SSIS Start 2 20
SSRS Deployment problem 5 63
Groupbox Control ? 2 16
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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

766 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