944,147 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1780
  • ASP.NET RSS
Feb 19th, 2007
0

SOS - datagrid problem

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
c# seeker is offline Offline
7 posts
since Feb 2007
Feb 20th, 2007
0

Re: SOS - datagrid problem

Which event is this code running from?
Did you trace with Studio (debug)?
Reputation Points: 13
Solved Threads: 4
Junior Poster in Training
nikkiH is offline Offline
79 posts
since Dec 2006
Feb 23rd, 2007
0

Re: SOS - datagrid problem

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
c# seeker is offline Offline
7 posts
since Feb 2007
Feb 23rd, 2007
0

Re: SOS - datagrid problem

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.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Visual Studio 2005 Application Error
Next Thread in ASP.NET Forum Timeline: Windows script host and filesystemobject - pls help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC