473,387 Members | 3,810 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,387 software developers and data experts.

problem in the datagrid

hi to all;
i have in my site a datagrid that is used to show the data about the user who registered to the site(lastname,firstname,...).

the idea from this datagrid that the admin can view the data of each person who is registered to the site, and then he can choose one of them and delete him.

what i did is that in the final column i put a link button (btndelete) named "delete" in each row so when the admin click on the delete
button , the user who is in the same row should be deleted

so, in ItemCommand event of datagrid i wrote this code:

if(e.CommandName=="btndelete")
{
int userid=System.Convert.ToInt32(e.CommandArgument);

SqlConnection conn=new SqlConnection();

conn.ConnectionString="DataSource=(AMIRA);InitialC atalog=Northwind;Integrated Security=SSPI";

SqlCommand comm=new SqlCommand();

comm.Connection=conn;

comm.CommandText="delete userid from register where userid=@userid ";
comm.Parameters.Add("@userid",userid);
conn.Open();

comm.ExecuteNonQuery();

conn.Close();
}

after running, and when i clicked on button delete in the first row to delete the first user , an error appeared:

"Input string was not in a correct format"

and the error on line:

int userid=System.Convert.ToInt32(e.CommandArgument);

so , please if anyone know how to solve this problem, please reply to me as soon as possible

thanks...
Jun 21 '07 #1
1 1088
Lit
If you go into debug mode, do you see an integer for e.CommandArgument ?
<merowrote in message news:ew**************@TK2MSFTNGP04.phx.gbl...
hi to all;
i have in my site a datagrid that is used to show the data about the user
who registered to the site(lastname,firstname,...).

the idea from this datagrid that the admin can view the data of each
person who is registered to the site, and then he can choose one of them
and delete him.

what i did is that in the final column i put a link button (btndelete)
named "delete" in each row so when the admin click on the delete
button , the user who is in the same row should be deleted

so, in ItemCommand event of datagrid i wrote this code:

if(e.CommandName=="btndelete")
{
int userid=System.Convert.ToInt32(e.CommandArgument);

SqlConnection conn=new SqlConnection();

conn.ConnectionString="DataSource=(AMIRA);InitialC atalog=Northwind;Integrated
Security=SSPI";

SqlCommand comm=new SqlCommand();

comm.Connection=conn;

comm.CommandText="delete userid from register where userid=@userid ";
comm.Parameters.Add("@userid",userid);
conn.Open();

comm.ExecuteNonQuery();

conn.Close();
}

after running, and when i clicked on button delete in the first row to
delete the first user , an error appeared:

"Input string was not in a correct format"

and the error on line:

int userid=System.Convert.ToInt32(e.CommandArgument);

so , please if anyone know how to solve this problem, please reply to me
as soon as possible

thanks...

Jun 21 '07 #2

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

Similar topics

2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
0
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some...
1
by: Joe Bloggs | last post by:
I am trying display the contents of a table in a web page, select certain rows from that table and then display the fields that I have selected (now table columns) as text in a Label object....
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
7
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.