private void GridBind()
        {
            try
            {
                DAL = new DataAccessLayer();
                DataTable dtbl = DAL.GetAllPolls();
                gvPolls.DataSource = dtbl;
                gvPolls.DataBind();

                DropDownList ddl = gvPolls.FooterRow.FindControl("ddlPollRoleFooter") as DropDownList;

                List <ListItem>             Role_Names = new List <ListItem>();
                Dictionary <string, string> list       = DAL.GetRoleName();
                foreach (KeyValuePair <string, string> entry in list)
                {
                    Role_Names.Add(new ListItem(entry.Key, entry.Value.ToString()));
                }
                ddl.Items.AddRange(Role_Names.ToArray());
            }
            catch (Exception ex)
            {
                lblErrorMessage.Visible   = true;
                lblErrorMessage.Text      = "DataBinding Exception: " + ex.Message;
                lblErrorMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
        private void GridSearch()
        {
            lblException.Visible = false;
            string txtSearchValue = txtSearch.Text.ToLower();
            int    length         = txtSearchValue.Length;

            try
            {
                if (length >= 3)
                {
                    DAL = new DataAccessLayer();
                    DataTable dtbl     = DAL.GetSearchPolls(ddlSearch.SelectedValue, txtSearch.Text);
                    int       countrow = dtbl.Rows.Count;
                    if (countrow == 0)
                    {
                        lblSearchError.Visible   = true;
                        lblSearchError.Text      = "No Records Found";
                        lblSearchError.ForeColor = System.Drawing.Color.Red;
                        gvPolls.Visible          = false;
                        lblException.Visible     = false;
                    }
                    else
                    {
                        lblSearchError.Visible = false;
                        gvPolls.Visible        = true;
                        gvPolls.DataSource     = dtbl;
                        gvPolls.DataBind();

                        DropDownList ddl = gvPolls.FooterRow.FindControl("ddlPollRoleFooter") as DropDownList;

                        List <ListItem>             Role_Names = new List <ListItem>();
                        Dictionary <string, string> list       = DAL.GetRoleName();
                        foreach (KeyValuePair <string, string> entry in list)
                        {
                            Role_Names.Add(new ListItem(entry.Key, entry.Value.ToString()));
                        }
                        ddl.Items.AddRange(Role_Names.ToArray());
                    }
                }
                else
                {
                    lblErrorMessage.Visible  = false;
                    lblSearchError.Visible   = true;
                    lblSearchError.Text      = "Please enter minimum 3 characters";
                    lblSearchError.ForeColor = System.Drawing.Color.Red;
                    lblException.Visible     = false;
                }
            }
            catch (Exception ex)
            {
                lblErrorMessage.Visible   = true;
                lblErrorMessage.Text      = "Search Exception: " + ex.Message;
                lblErrorMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
        protected void gvPolls_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            DAL = new DataAccessLayer();

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddl = (DropDownList)e.Row.FindControl("ddlEditPollRole");

                if (ddl != null)
                {
                    List <ListItem> PollRole = new List <ListItem>();
                    ddl.SelectedIndex = 1;
                    Dictionary <string, string> list = DAL.GetRoleName();
                    foreach (KeyValuePair <string, string> entry in list)
                    {
                        PollRole.Add(new ListItem(entry.Key, entry.Value.ToString()));
                    }
                    ddl.Items.AddRange(PollRole.ToArray());
                    DataRowView dr = e.Row.DataItem as DataRowView;
                    ddl.SelectedValue = dr["PollRole"].ToString();
                }
            }
        }