Solved

ASP.NET Datagrid problem

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

 
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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syntax Error 2 62
Vb. Net application freezes 9 45
VB.NET 2008 Populate DataModel with DataTable 44 28
RLDC Reporting in Visual studio 11 13
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

806 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