Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void btnSend_Click(object sender, EventArgs e)
    {
        
        dt.Columns.Add("MenuName");        

        foreach (GridViewRow grdRow in grdMenuList.Rows)
        {
            if (((CheckBox)grdRow.FindControl("chkSelect")).Checked)
            {
                DataRow drow = dt.NewRow();
                drow["MenuName"] = grdRow.Cells[1].Text;
                //drow["fname"] = grdRow.Cells[2].Text;
                //drow["lname"] = grdRow.Cells[3].Text;
                dt.Rows.Add(drow);
            }
        }
        if (dt.Rows.Count > 0)
        {
            grdMenuPermitted.DataSource = dt;
            grdMenuPermitted.DataBind();
        }        
    }

protected void grdMenuPermitted_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        
       
    }


*** I want to get data from datatable in gridview rowdataevent for templatefield..
Posted

1 solution

C#
protected void grdMenuPermitted_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView dr = (DataRowView)e.Row.DataItem;
           
            e.Row.Cells[0].Text = dr["MenuName"].ToString();
           
            
        }
    }
 
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