I have to display data in a gridview dynamically that is without using standard datasource from gridview.So I have used dataset to populate and display data in dynamic gridview.
Code in .aspx file <form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
</div>
</form>
Code in .aspx.cs file protected void Page_Load(object sender, EventArgs e)
{
string strcon = ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString;
SqlConnection con = new SqlConnection(strcon);
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [EmpInfo2]", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
}
I have a column as Gender with datatype as bit(stores true or false) in SQL database.So when we obtain data in gridview in Gender column checkbox is displayed either checked or unchecked.but i want to display Male or Female(Say for checked it must display male for unchecked it must display female) instead of checkbox.I know that by using template databound fields in standard gridview it can be achieved but here it is dynamic where no databound field can be edited or templated.what can be done?