473,387 Members | 1,892 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.

Clicked Cell still appear after I leave and re-enter the form? --C#

Hi, everyone.
I got a weird problem for my C# program. In my program, I use a DataGrid to display data. I bind the DataGrid to a DataTable. I made all the cells in DataGrid ReadOnly as True. So I can only Click on the cell but not change them.

Now, after I display the data, I clicked on one cell, then I clicked a button which will *virtually* go to the other form.(The reason why I said *virtually* is because I only use one form for the whole program. Every time I hit a button, according to the Caption shown on the button, i will hide some content in the form, and display some contents. So it looks like we are going to different forms, but actually we only got one form in total).

Back to the problem, After I *virtually* exit the data display form, I click a button to re-enter to data display form which will request me to type username and password to show the data. Before I entered username and password, the DataGrid area should appear purely blank, just as first time coming in. But what I actually got is the cell i clicked before appeared in the DataGrid area, and only that cell!

I tried to use DataGrid.DataSource = Null to clear the DataGrid, but it didn't work. I even tried to do ((DataTable)DataGrid.DataSource).Clear() before I dereference the DataSource from DataGrid, it still didn't work. Anyone got an idea of it?




PS: Sorry for my long post, and since i couldn't figure out which part got wrong, so i couldn't post the code coz it's too long.
Dec 22 '06 #1
2 2070
karthi84
271 100+
try with this code for clearing the datagrid if not i will try for a new solution for you
Expand|Select|Wrap|Line Numbers
  1. DataGrid1.DataSource="";
  2. DataGrid1.DataBind();
  3.  
Dec 28 '06 #2
kenobewan
4,871 Expert 4TB
My suggestion is that you bind the data to the datagrid in page load, but set the datagrid view to false. Once you have dealt with the username & password, you can set the datagrid visibility to true. You may display a message to this affect to the user.

Hope that this helps.
Dec 28 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Paul Daly (MCP) | last post by:
How do you access the value of a cell in a Windows form datagrid? I know this is how you would do it using an ASP.NET datagrid: DataGrid1.Items.Cells.Text However, "Items" is not available in...
1
by: ilPostino | last post by:
Hi, I want to create a control that when dragged from the Toolbar onto a form doesn't appear on the form but instead appears in that magical area below the form. Something similar to a Timer...
4
by: Dot net work | last post by:
If I have got 2 web user controls on my aspx form, and one web user control has got some validator controls on it, what I find is that if I enter in some "bad data" in to some text boxes on the...
10
by: Mr Newbie | last post by:
DropDown lists and Listboxes do not appear in the list of controls and values passed back to the server on PostBack in Request.Form object. Can someone confirm this to be correct and possibly...
4
by: SStory | last post by:
I want to use F6,F7,etc for an entire form. Have key preview to true and it works everywhere but on the grid. On the grid sometimes it works and sometimes not. Appears that if I am in a cell...
2
by: Nick Douglas | last post by:
We want our company logo to appear on the forms in our database. The logo is on our homepage. Is there a way to link it? (rather than embed it).
4
by: Hmunawar | last post by:
I m using a data gridveiw control in Window forms application and i want to delete the record on which the user clicks, for this purpose i need to get the index of the clicked row. How can i get...
5
by: ramprat | last post by:
Hi, Using Access 2003 how do you read the value from a particular cell (row/column combination) in the current record of a continuous form and use this value elsewhere? For example, how do you...
3
by: John Dale | last post by:
This is the form that I created. http://postimg.org/image/pe3abqek3/ Specifically, I've got problems on updating the current date, adding specified values on fields(vacation, sick, vs_total) and...
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: 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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.