grd.AllowSorting = true
if (cell.Text == "Login") { cell.Text = "TUSHAR"; }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Configuration; namespace RNDWeb { public partial class GridViewRND : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { BindDataUsingDataSet(); } public void BindDataUsingDataSet() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RNDLocal"].ConnectionString); SqlCommand cmd = new SqlCommand("select ID,Login from users where login like 'survey%'", con); SqlDataAdapter dad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); dad.Fill(ds); GridView grd = new GridView(); grd.RowDataBound += GridView_RowDataBound; placeholder.Controls.Add(grd); grd.AllowSorting = true; grd.DataSource = ds; grd.DataBind(); } public void GridView_RowDataBound(Object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex == 0) { e.Row.Visible = false; } if (e.Row.RowType == DataControlRowType.Header) { foreach (TableCell cell in e.Row.Cells) { if (cell.Text == "Login") { cell.Text = "TUSHAR"; } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)