SOS - datagrid problem

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2007
Posts: 7
Reputation: c# seeker is an unknown quantity at this point 
Solved Threads: 1
c# seeker c# seeker is offline Offline
Newbie Poster

SOS - datagrid problem

 
0
  #1
Feb 19th, 2007
I'm using the following code to pass data to a table in my database. The datagrid consists of a bound column and 3 template columns (2 textboxes and a chackebox).

The problem is that the values of these template columns cannot be read. (i.e. in the following code, values of qtyTextBox and desTextBox are "" and addChackBox.Checked is always 'false' even if it is checked).

HELP!!!

for (int i = 0; i < dgaddf.Items.Count; i++)
{
DataGridItem item = dgaddf.Items[i];
string it = item.Cells[1].Text.ToString();
TextBox qtyTextBox (TextBox)item.FindControl("txtQ");
TextBox desTextBox=(TextBox)item.FindControl("txtD");
CheckBox addCheckBox = (CheckBox)item.FindControl("Chk1");
if (addCheckBox.Checked)
{
br.createFloRec(it, int.Parse(qtyTextBox.Text), desTextBox.Text, connect1.con); 
// the function that adds data to the DB
}
}
Last edited by c# seeker; Feb 19th, 2007 at 4:32 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 79
Reputation: nikkiH is an unknown quantity at this point 
Solved Threads: 4
nikkiH's Avatar
nikkiH nikkiH is offline Offline
Junior Poster in Training

Re: SOS - datagrid problem

 
0
  #2
Feb 20th, 2007
Which event is this code running from?
Did you trace with Studio (debug)?
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 7
Reputation: c# seeker is an unknown quantity at this point 
Solved Threads: 1
c# seeker c# seeker is offline Offline
Newbie Poster

Re: SOS - datagrid problem

 
0
  #3
Feb 23rd, 2007
I've traced it with debug but it doesn't show any error. But the data is nt added to the database.

The coding is triggered by the event handler of a button (which is outside the datagrid).

Tried everything possible. Couldn't find a solution. So opted for a dynamic table rather than a datagrid.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: SOS - datagrid problem

 
0
  #4
Feb 23rd, 2007
How was your datagrid boiund? in the Page_Load? if so is it inside an if(!IsPostBack) statement block? if it isn't it will be rebound (everything reset to previous values) on postback BEFORE the click event fires.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC