Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table name dbo.tblPSData consisting numbers or records related to 6 different entity. What i do here i assign a Unique ID to these 6 different entity like...
101-For Schools
102-Transports
103-Hospitals
104-Functions
106-Security

these entity consisting no. of records and i used datagrid view to show total number of records enter in single entity on particular date...

CODE Service_Name Date Total_Records_Enter

101 Schools 14-03-2011 36
102 Transport 16-03-2011 126
103 Hospital 16-03-2011 76
104 Function 18-02-2011 23
106 Security 12-04-2011 46

Now what i want when i double click on any single row of datagrid view a new windows form loaded and it show me the total number of records enter on particular date show in gridview on entity.

UPDATE:
C#
private string _id;
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }
        private DateTime dt;
        public DateTime _dt
        {
            get { return dt; }
            set{dt=value;}
        }
        private void DataShowForm_Load(object sender, EventArgs e)
        {
            string s;
            SqlConnection con = new SqlConnection("data source=ASHU-PC;initial catalog=login;integrated Security=true");
            SqlDataAdapter adp = new SqlDataAdapter("select * from tblPSData where code_id='" + _id + "' and SDate='"+_dt+"' order by serial_no", con);
            DataSet ds = new DataSet();
            adp.Fill(ds,"tm");(This line came with exception "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.")
            dataGridView1.DataSource = ds.Tables["tm"];
        }


what i have to do ???
HELP


THANKS
Posted
Updated 30-May-13 1:17am
v2
Comments
Sunasara Imdadhusen 30-May-13 0:47am    
Have u written any code?
Mayur Panchal 30-May-13 0:55am    
This is your re-post, you have asked this question before and solved it. Below is link :
How to show all record on cell double click event in datagrid view to new winform using datagrid view?[^]
ashu_dhiman 30-May-13 1:03am    
mayur there is difference b/w the last one and this. Last is base on Id Only but this is according to ID and Particular date...
ashu_dhiman 30-May-13 0:57am    
yes but it show's all the records related to particular ID but i want only those records who enter on particular date for e.g: when i double click on row who has code-101, service_name:School, Date-14-03-2011, Total_Records_Enter-36

it only shows 36 records enter in School Service on Date-14-03-2011
Mayur Panchal 30-May-13 1:17am    
Then, you can do this stuff same as last solution, build another property for date and put extra condition on that method used to fetch data for grid. Simple !!!

1 solution

As I can see you are trying to open a new form(say Form2) on the DataGridView.CellClick Event[^]. The best way is to change the constructor of Form2 to accept the id value, and process it as it is constructed. You can show the details on Form2 based on the ID passed by Form1.

Alternatives : Passing Data Between Forms[^]


--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900