By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,965 Members | 1,479 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,965 IT Pros & Developers. It's quick & easy.

Databound Textbox - DataSet not getting updated value

P: n/a
I have one databound TextBox on a page with one button. The TextBox loads
the correct SQL record data but typing a new string into the Textbox fails
to change the DataSet. Any ideas? There must be some way to force the
edited TextBox to update the DataSet since it appears to not be done
automatically.

//--------------------------------------------------------------------------
--------------------------
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet21);
Page.DataBind();
}
//--------------------------------------------------------------------------
--------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
//dataSet21.AcceptChanges();
DataSet ds = dataSet21.GetChanges();
sqlDataAdapter1.Update(dataSet21);
}
//--------------------------------------------------------------------------
--------------------------
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Where are you taking the data from the textbox and placing it into the
dataset?
"John Rose" <jo*******@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl...
I have one databound TextBox on a page with one button. The TextBox loads
the correct SQL record data but typing a new string into the Textbox fails
to change the DataSet. Any ideas? There must be some way to force the
edited TextBox to update the DataSet since it appears to not be done
automatically.

//-------------------------------------------------------------------------- --------------------------
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet21);
Page.DataBind();
}
//-------------------------------------------------------------------------- --------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
//dataSet21.AcceptChanges();
DataSet ds = dataSet21.GetChanges();
sqlDataAdapter1.Update(dataSet21);
}
//-------------------------------------------------------------------------- --------------------------

Nov 18 '05 #2

P: n/a
How do you do that?

Actually the Button1_Click event is:
//---------------------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.Update(dataSet21);
}
//---------------------------------------
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
Where are you taking the data from the textbox and placing it into the
dataset?
"John Rose" <jo*******@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl...
I have one databound TextBox on a page with one button. The TextBox loads the correct SQL record data but typing a new string into the Textbox fails to change the DataSet. Any ideas? There must be some way to force the
edited TextBox to update the DataSet since it appears to not be done
automatically.

//--------------------------------------------------------------------------
--------------------------
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet21);
Page.DataBind();
}

//--------------------------------------------------------------------------
--------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
//dataSet21.AcceptChanges();
DataSet ds = dataSet21.GetChanges();
sqlDataAdapter1.Update(dataSet21);
}

//--------------------------------------------------------------------------
--------------------------


Nov 18 '05 #3

P: n/a
You've got to place the text value into the dataset column for a given
row...

DataSet.Tables("tableName").Rows(whichRowToWorkWit h).Item("columnName") =
textbox.text

You also need to make sure your DataAdapter has a valid (and correct)
update, delete and insert statement associated with its commands.

The fact that the textbox is bound does not mean that if you change its
value the dataset will immediately change, you have to manually update the
dataset with the value from the textbox.

"John Rose" <jo*******@yahoo.com> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
How do you do that?

Actually the Button1_Click event is:
//---------------------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.Update(dataSet21);
}
//---------------------------------------
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
Where are you taking the data from the textbox and placing it into the
dataset?
"John Rose" <jo*******@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl...
I have one databound TextBox on a page with one button. The TextBox loads the correct SQL record data but typing a new string into the Textbox fails to change the DataSet. Any ideas? There must be some way to force the edited TextBox to update the DataSet since it appears to not be done
automatically.

//--------------------------------------------------------------------------
--------------------------
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet21);
Page.DataBind();
}

//--------------------------------------------------------------------------
--------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
//dataSet21.AcceptChanges();
DataSet ds = dataSet21.GetChanges();
sqlDataAdapter1.Update(dataSet21);
}

//--------------------------------------------------------------------------
--------------------------



Nov 18 '05 #4

P: n/a
Thanks. Looks like in C# I have to do:

private void Button1_Click(object sender, System.EventArgs e)
{
dataSet21.Tables["tablename"].Rows[intRow].BeginEdit();
dataSet21.Tables["tablename"].Rows[intRow]["columnname"] = textbox.Text;
dataSet21.Tables["tablename"].Rows[intRow].EndEdit();
sqlDataAdapter1.Update(dataSet21);
}
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
You've got to place the text value into the dataset column for a given
row...

DataSet.Tables("tableName").Rows(whichRowToWorkWit h).Item("columnName") =
textbox.text

You also need to make sure your DataAdapter has a valid (and correct)
update, delete and insert statement associated with its commands.

The fact that the textbox is bound does not mean that if you change its
value the dataset will immediately change, you have to manually update the
dataset with the value from the textbox.

"John Rose" <jo*******@yahoo.com> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
How do you do that?

Actually the Button1_Click event is:
//---------------------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.Update(dataSet21);
}
//---------------------------------------
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
Where are you taking the data from the textbox and placing it into the
dataset?
"John Rose" <jo*******@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl...
> I have one databound TextBox on a page with one button. The TextBox

loads
> the correct SQL record data but typing a new string into the Textbox

fails
> to change the DataSet. Any ideas? There must be some way to force the > edited TextBox to update the DataSet since it appears to not be done
> automatically.
>
>

//--------------------------------------------------------------------------
> --------------------------
> private void Page_Load(object sender, System.EventArgs e)
> {
> sqlDataAdapter1.Fill(dataSet21);
> Page.DataBind();
> }
>

//--------------------------------------------------------------------------
> --------------------------
> private void Button1_Click(object sender, System.EventArgs e)
> {
> //dataSet21.AcceptChanges();
> DataSet ds = dataSet21.GetChanges();
> sqlDataAdapter1.Update(dataSet21);
> }
>

//--------------------------------------------------------------------------
> --------------------------
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.