473,465 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4247
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.