<asp:GridView ID="GridView2" runat="server" GridLines="None" onrowdatabound="GridView2_RowDataBound" align="center" PageSize="4" onpageindexchanging="GridView2_PageIndexChanging" ShowHeaderWhenEmpty="true" AllowPaging="true" > <AlternatingRowStyle BackColor="White" /> <RowStyle BackColor="#CCCCCC" /> </asp:GridView>
protected void Page_Load(object sender, EventArgs e) { Recentinternship(); } protected void Recentinternship() { SqlConnection con = new SqlConnection("Data Source=jayraj-pc\\sqlexpress;Initial Catalog=Internship;Integrated Security=True;Pooling=False"); con.Open(); string str = "select B.CompanyLogo as ' ',A.Title,A.InternshipStartDate,A.ApplicationDeadline,A.Duration,A.InternshipCity,A.Category,A.Stipend,A.InternshipID,A.Degree,A.Branch,A.CompanyID,A.Title,A.CompanyName from Internship AS A INNER JOIN Companies AS B ON A.CompanyID=B.CompanyID "; SqlCommand cmd = new SqlCommand(str, con); SqlDataAdapter da = new SqlDataAdapter(cmd); SqlDataReader dr = cmd.ExecuteReader(); GridView2.DataSource = dr; GridView2.DataBind(); //GridView2.BottomPagerRow.Visible = true; dr.Close(); con.Close(); } protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { string str = " Category :" + e.Row.Cells[6].Text + "<br/>Duration :" + e.Row.Cells[4].Text + "<br/>InternshipCity :" + e.Row.Cells[5].Text + "<br/>Stipend :" + e.Row.Cells[7].Text + "<br/>InternshipStartDate :" + e.Row.Cells[2].Text + "<br/>ApplicationDeadline :" + e.Row.Cells[3].Text + "<br/>Required Degree :" + e.Row.Cells[9].Text + "<br/>Required Branch :" + e.Row.Cells[10].Text; e.Row.Cells[1].Text = str; //e.Row.Cells[1].Visible = false; //e.Row.Cells[2].Visible = false; e.Row.Cells[3].Visible = false; e.Row.Cells[4].Visible = false; e.Row.Cells[5].Visible = false; e.Row.Cells[6].Visible = false; e.Row.Cells[7].Visible = false; e.Row.Cells[8].Visible = false; e.Row.Cells[9].Visible = false; e.Row.Cells[10].Visible = false; e.Row.Cells[11].Visible = false; e.Row.Cells[12].Visible = false; e.Row.Cells[13].Visible = false; if (GridView2.Rows.Count > 0) { GridView2.HeaderRow.Cells[0].Text = " "; GridView2.HeaderRow.Cells[1].Text = " "; GridView2.HeaderRow.Cells[2].Text = " "; } Image img = new Image(); img.ID = "abc"; img.ImageUrl = e.Row.Cells[0].Text; e.Row.Cells[0].Controls.Add(img); Button btn = new Button(); //btn.Text = "preview"; e.Row.Cells[2].Controls.Add(btn); btn.CausesValidation = false; btn.Text = "View and Apply"; if (Session.Count > 0) { btn.PostBackUrl = "Apply_internship.aspx?InternshipID=" + e.Row.Cells[8].Text + "&CompanyID=" + e.Row.Cells[11].Text + "&Title=" + e.Row.Cells[12].Text + "&CompanyName=" + e.Row.Cells[13].Text + ""; } else { btn.PostBackUrl = "Apply_login.aspx"; } } protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView2.PageIndex = e.NewPageIndex; Recentinternship(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)