473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

update a row in datagrid

Actually my code looks like this....

private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.Columns[5].Visible=true;
DataGrid1.Columns[6].Visible=true;
TextBox t1=new TextBox();
TextBox t6=new TextBox();
TextBox t7=new TextBox();

t1.Text=((TextBox)e.Item.FindControl("TextBox10")) .Text
t2.Text=((TextBox)e.Item.Cells[2].FindControl("TextBox8")).Text; t3.Text=((TextBox)e.Item.Cells[3].FindControl("TextBox9")).Text;

SqlConnection con=DataAccessor.CreateConnection();
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandType=CommandType.Text;
cmd.CommandText=@"update tblPQOrder set
ProoductID="+t1.Text+","+"Quantity="+t2.Text+","+" UnitCost="+t3.Text+"where
ItemID="+DataGrid1.DataKeys[e.Item.ItemIndex];

cmd.ExecuteReader();
DataAccessor.CloseConnection(con);
cmd.Dispose();
Rebind();

}

the new value is not entering in to the code when i debug....Is there any
error in the SQL Update Statment???
--
Jijo kuruvila
trivandrum,Kerala,India
Nov 16 '05 #1
1 4246
Jijo,

It's hard to say, Without knowing the types of the columns, I can't
tell if you should be using a number or a string as the value.

Also, you should be using a parameterized statement here, and not
setting the values yourself.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jijo kuruvila" <ji******@msn.com> wrote in message
news:EB**********************************@microsof t.com...
Actually my code looks like this....

private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.Columns[5].Visible=true;
DataGrid1.Columns[6].Visible=true;
TextBox t1=new TextBox();
TextBox t6=new TextBox();
TextBox t7=new TextBox();

t1.Text=((TextBox)e.Item.FindControl("TextBox10")) .Text;
t2.Text=((TextBox)e.Item.Cells[2].FindControl("TextBox8")).Text;
t3.Text=((TextBox)e.Item.Cells[3].FindControl("TextBox9")).Text;

SqlConnection con=DataAccessor.CreateConnection();
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandType=CommandType.Text;
cmd.CommandText=@"update tblPQOrder set
ProoductID="+t1.Text+","+"Quantity="+t2.Text+","+" UnitCost="+t3.Text+"where
ItemID="+DataGrid1.DataKeys[e.Item.ItemIndex];

cmd.ExecuteReader();
DataAccessor.CloseConnection(con);
cmd.Dispose();
Rebind();

}

the new value is not entering in to the code when i debug....Is there any
error in the SQL Update Statment???
--
Jijo kuruvila
trivandrum,Kerala,India

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
3
by: D. Shane Fowlkes | last post by:
I have a Datagrid which in theory, should allow you to edit and update the records. I've stripped my test page down so that it's only attempting to update one field - "description". Yet when I...
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
4
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft...
3
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
1
by: Sharon | last post by:
Hello All, Is it possible to update Sql Table through DataGrid. I have a DataGrid which is being populated through a stored procedure, all i wanted to do is to update one field...
1
by: geeteshss | last post by:
Dear all, actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.