<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="false" ShowHeaderWhenEmpty="true" EmptyDataText="No records Found"> </asp:GridView>
public partial class Pending : System.Web.UI.Page { SqlConnection con = new SqlConnection("Data Source=jayraj-pc\\sqlexpress;Initial Catalog=Internship;Integrated Security=True;Pooling=False"); protected void Page_Load(object sender, EventArgs e) { BindGridviewData(); } protected void BindGridviewData() { con.Open(); string p = "Pending"; SqlCommand cmd = new SqlCommand("select FirstName,LastName,LocationPreference,College,Status,null as 'Action',null as 'Actions',UserID,InternshipID from UsersApplied where InternshipID='" + Request.QueryString["InternshipID"].ToString() + "' and Status='" + p + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); //DataTable dt = new DataTable(); //da.Fill(dt); // if (dt.Rows.Count > 0) if (ds.Tables[0].Rows.Count == 0) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); GridView1.DataSource = ds; GridView1.DataBind(); int columncount = GridView1.Rows[0].Cells.Count; GridView1.Rows[0].Cells.Clear(); GridView1.Rows[0].Cells.Add(new TableCell()); GridView1.Rows[0].Cells[0].ColumnSpan = columncount; GridView1.Rows[0].Cells[0].Text = "No Records Found"; //GridView1.DataSource = dt; //GridView1.DataBind(); //Pending(); } else { GridView1.DataSource = ds; GridView1.DataBind(); } con.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)