Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
protected void gv1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        ModalPopupExtender1.Show();
        tb.Text = gv1.Rows[e.NewSelectedIndex].Cells[2].Text;
        tb1.Text = gv1.Rows[e.NewSelectedIndex].Cells[3].Text;
       

 IEnumerable<datarow> m = (from x in BAL.INSTANCE.disempdetails().AsEnumerable() where x.EID == Convert.ToInt32(gv1.Rows[e.NewSelectedIndex].Cells[2].Text) select new { x.DID, x.DNAME });</datarow>

        DataTable dt1 = new DataTable();
        dt1.Columns.Add("DID", typeof(string));
        dt1.Columns.Add("DNAME", typeof(string));
        m.CopyToDataTable(dt1, System.Data.LoadOption.PreserveChanges);
        gv.DataSource = m;
        gv.DataBind();
        ViewState["i"] = 1;
        tb1.Focus();
    }
Posted
Updated 25-Apr-13 22:13pm
v4
Comments
Naz_Firdouse 26-Apr-13 4:02am    
what is happening with this code???
Explain the issues...
Francisco T. Chavez 26-Apr-13 18:38pm    
Why don't you just loop through the list and add the each item to the table?
ChienVH 4-May-13 14:13pm    
For your reference:
http://www.codeproject.com/Articles/83271/Convert-a-Generic-List-to-a-Datatable
http://www.dotnetperls.com/convert-list-datatable

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