M
Morris Neuman
Hi,
I have a button (Update) and hve the click event defined as below. The
update event does not give me an error, however the record is not updated
either. Both AccessDataSource1 and SqlDataSource1 are defined as
AccessDataSource and SqlDataSource controls.
I have 2 textboxes (NumToDial and AttID). The textboxes and button are as
defined below.
<asp:TextBox ID="AttID" runat="server"></asp:TextBox>
<asp:TextBox ID="NumToDial" runat="server"></asp:TextBox>
<asp:Button ID="Update" runat="server" onclick="Update_Click"
Text="Update" />
protected void Update_Click(object sender, EventArgs e)
{
string id = ConfigurationManager.AppSettings["MyDataSource"];
Control datasourcecontrol = this.FindControl(id);
if (id.Equals("SqlDataSource1"))
{
GridView1.DataSourceID = "SqlDataSource1";
SqlDataSource1.UpdateCommand = "UPDATE Attendant SET
Attendant.ExtensionToDial = '" + NumToDial.Text + "' WHERE
(Attendant.AttendantID)= '" + AttID.Text + "'";
GridView1.DataBind();
GridView1.Visible = true;
}
else if (id.Equals("AccessDataSource1"))
{
GridView1.DataSourceID = "AccessDataSource1";
AccessDataSource1.UpdateCommand = "UPDATE Attendant SET
Attendant.ExtensionToDial = '" + NumToDial.Text + "' WHERE
(Attendant.AttendantID)= '" + AttID.Text + "'";
GridView1.DataBind();
GridView1.Visible = true;
}
}
I have tried different ways to define the parameters but keep getting syntax
errors when I do. When I do a similar .SelectCommand it works, however the
..Update give no error but the record is not updated either.
Can you please tell me what is wrong with the .UpdateCommand?
I have a button (Update) and hve the click event defined as below. The
update event does not give me an error, however the record is not updated
either. Both AccessDataSource1 and SqlDataSource1 are defined as
AccessDataSource and SqlDataSource controls.
I have 2 textboxes (NumToDial and AttID). The textboxes and button are as
defined below.
<asp:TextBox ID="AttID" runat="server"></asp:TextBox>
<asp:TextBox ID="NumToDial" runat="server"></asp:TextBox>
<asp:Button ID="Update" runat="server" onclick="Update_Click"
Text="Update" />
protected void Update_Click(object sender, EventArgs e)
{
string id = ConfigurationManager.AppSettings["MyDataSource"];
Control datasourcecontrol = this.FindControl(id);
if (id.Equals("SqlDataSource1"))
{
GridView1.DataSourceID = "SqlDataSource1";
SqlDataSource1.UpdateCommand = "UPDATE Attendant SET
Attendant.ExtensionToDial = '" + NumToDial.Text + "' WHERE
(Attendant.AttendantID)= '" + AttID.Text + "'";
GridView1.DataBind();
GridView1.Visible = true;
}
else if (id.Equals("AccessDataSource1"))
{
GridView1.DataSourceID = "AccessDataSource1";
AccessDataSource1.UpdateCommand = "UPDATE Attendant SET
Attendant.ExtensionToDial = '" + NumToDial.Text + "' WHERE
(Attendant.AttendantID)= '" + AttID.Text + "'";
GridView1.DataBind();
GridView1.Visible = true;
}
}
I have tried different ways to define the parameters but keep getting syntax
errors when I do. When I do a similar .SelectCommand it works, however the
..Update give no error but the record is not updated either.
Can you please tell me what is wrong with the .UpdateCommand?