473,289 Members | 1,848 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,289 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 2067
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.