Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is code which i have used in windows application now i want used in web how can do that..


C#
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
       {
           switch (e.ColumnIndex)
           {
               case 0:
                   if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                   {
                       string cat_id = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                       DataGridViewComboBoxCell dgvcc;
                       dgvcc =(DataGridViewComboBoxCell) dataGridView1.Rows[e.RowIndex].Cells[1];
                       dgvcc.DisplayMember = "item_name";
                       dgvcc.ValueMember = "item_id";
                       dgvcc.DataSource = DAL.item.view(cat_id);

                   }
                   break;
               case 1:
                   if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                   {
                       DataGridViewComboBoxCell dgvcc;
                       dgvcc = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[1];
                       DataTable dt = (DataTable)dgvcc.DataSource;
                       string item_id = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                       DataRow[] dr = dt.Select("item_id=" + item_id);

                       dataGridView1.Rows[e.RowIndex].Cells[2].Value = dr[0]["rate"];
                       //MessageBox.Show(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());

                   }
                   break;
               case 3:
                   if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                   {
                       int rate = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value);
                       int qty = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[3].Value);
                       int total = rate * qty;
                       dataGridView1.Rows[e.RowIndex].Cells[4].Value = total;
                       gtotal += total;
                       lblTotal.Text = gtotal.ToString();
                   }
                   break;



           }
       }
Posted
Updated 16-Nov-12 22:49pm
v2
Comments
Nandakishore G N 17-Nov-12 5:36am    
Its Better To specify the reason behind the code written..so that anyone can help you and can suggest better way..
n.podbielski 17-Nov-12 6:13am    
Put this on web page .cs file. Fix compilation errors. Run. Fix runtime errors. Congratulations you are using THIS code.
Sergey Alexandrovich Kryukov 17-Nov-12 22:44pm    
It will be THAT code, not THIS. :-)
--SA
n.podbielski 18-Nov-12 3:15am    
Is this some English Grammar issue? I don't see much diffrence. Like "who" and "whom" :p
Sergey Alexandrovich Kryukov 18-Nov-12 11:13am    
No, no, you just did not get it, perhaps I poorly expressed it. See, int the question title: "how to use THIS code". But you suggested to modify it, to fix errors. It will make another, different code, not "THIS". In other words, the problem is not solvable at all, because the code which might work won't be exactly "THIS". :-)
--SA

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