swati agrawal

swati agrawal

  • NA
  • 20
  • 98k

how to find value of label in gridview

Mar 10 2011 5:36 AM

i have a label in itemtemplate of gridview.want to access value of dat label bt its giving me null value.my code is:

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }

        public void bind()
        {
            string qry = "SELECT tbl_artists.name as ArtistName, tbl_artists.profilePic as Pic,tbl_venues.name AS VenueNmae,convert(varchar(50),tbl_ArtistSchedule.Date,105)as Date, tbl_ArtistSchedule.Time FROM tbl_ArtistSchedule INNER JOIN tbl_artists ON tbl_ArtistSchedule.artistId = tbl_artists.artistId INNER JOIN tbl_venues ON tbl_ArtistSchedule.venueId = tbl_venues.venueId";
            ds = obj.fillds(qry);
            GridView1.DataSource = ds;
            GridView1.DataBind();
           
           
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Label lbl1 = (Label)e.Row.FindControl("lblday");
            string date = lbl1.Text;
           
        }


Answers (4)