Click here to Skip to main content
15,914,500 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Convert String to Int Pin
siva45526-May-10 0:39
siva45526-May-10 0:39 
AnswerRe: Convert String to Int Pin
Peace ON26-May-10 1:04
Peace ON26-May-10 1:04 
GeneralRe: Convert String to Int Pin
siva45526-May-10 1:41
siva45526-May-10 1:41 
GeneralRe: Convert String to Int Pin
FarmerHE26-May-10 1:59
FarmerHE26-May-10 1:59 
GeneralRe: Convert String to Int Pin
siva45526-May-10 2:41
siva45526-May-10 2:41 
GeneralRe: Convert String to Int Pin
michaelschmitt26-May-10 5:48
michaelschmitt26-May-10 5:48 
QuestionRetrive binary data from Sql Sever Database Pin
puja25-May-10 23:00
puja25-May-10 23:00 
AnswerRe: Retrive binary data from Sql Sever Database Pin
Peace ON25-May-10 23:35
Peace ON25-May-10 23:35 
GeneralRe: Retrive binary data from Sql Sever Database Pin
puja26-May-10 0:50
puja26-May-10 0:50 
GeneralRe: Retrive binary data from Sql Sever Database Pin
T M Gray26-May-10 7:52
T M Gray26-May-10 7:52 
GeneralRe: Retrive binary data from Sql Sever Database Pin
puja27-May-10 21:07
puja27-May-10 21:07 
GeneralRe: Retrive binary data from Sql Sever Database Pin
T M Gray28-May-10 5:14
T M Gray28-May-10 5:14 
QuestionModel PopUp Problem Pin
AtiqueJnp25-May-10 21:29
AtiqueJnp25-May-10 21:29 
AnswerRe: Model PopUp Problem Pin
michaelschmitt25-May-10 23:27
michaelschmitt25-May-10 23:27 
AnswerRe: Model PopUp Problem Pin
Andreas X27-May-10 2:12
professionalAndreas X27-May-10 2:12 
QuestionAJAX Tool Kit +ASP.Net Pin
chetan_agarwal25-May-10 21:14
chetan_agarwal25-May-10 21:14 
AnswerRe: AJAX Tool Kit +ASP.Net Pin
AtiqueJnp25-May-10 21:39
AtiqueJnp25-May-10 21:39 
AnswerRe: AJAX Tool Kit +ASP.Net Pin
Sandeep Mewara25-May-10 22:01
mveSandeep Mewara25-May-10 22:01 
GeneralRe: AJAX Tool Kit +ASP.Net Pin
chetan_agarwal25-May-10 23:36
chetan_agarwal25-May-10 23:36 
Questionhow could we know that a method is executing a certain point of time Pin
sainath43725-May-10 18:16
sainath43725-May-10 18:16 
Answer[Repost]: how could we know that a method is executing a certain point of time Pin
Sandeep Mewara25-May-10 18:32
mveSandeep Mewara25-May-10 18:32 
QuestionNeed way to access controls on page from a static method in codebehind. Pin
Adam Brown 325-May-10 10:29
Adam Brown 325-May-10 10:29 
I have an aspx page and and I utilize a static web method defined in the codebhenind of the page. I need a way to access controls on the page to do some databinding from this static method, but when I try to access the control I get the following error:

Error 1 An object reference is required for the non-static field, method, or property 'AccessRequestForm.AssignRole.UpdateRoleGrid

How do I access an instance of the page I am on from a static method? The codebehind I am using is included below:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using AccessRequestForm.UtilityServices;
using AccessRequestForm.BusinessServices;
using AccessRequestForm.Models;
using AjaxControlToolkit;

namespace AccessRequestForm
{
    public partial class AssignRole : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IQueryable<MasterRole> roleList = Role.SelectAll(Convert.ToInt32(strBUSelected));
                lstRoles.Items.Clear();
                foreach (MasterRole role in roleList)
                {
                    ListItem li = new ListItem(role.role_business_desc.ToString(), role.role_id.ToString());
                    lstRoles.Items.Add(li);
                }

                UpdateRoleGrid(roleList);

            }
        }

        public void UpdateRoleGrid(IQueryable<MasterRole> roleList)
        {
            //Databind the Grid
            grdRoles.DataSource = roleList;
            grdRoles.DataBind();
        }

        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod]
        public static string[] GetCompletionList(string prefixText, int count, string contextKey)
        {
            IQueryable<MasterRole> roleList = Role.SelectStartPattern(Convert.ToInt32(contextKey), prefixText);
            List<string> items = new List<string>(count);
            int i = 0;
            foreach (MasterRole role in roleList)
            {
                if (i++ < count)
                {
                    string strName = role.role_business_desc.ToString();
                    items.Add(strName);
                }
            }
            
            //I get the error here "An object reference is required for the non-static field, method, or property 'AccessRequestForm.AssignRole.UpdateRoleGrid"
            UpdateRoleGrid(roleList);

            return items.ToArray();
        }
    }
}

AnswerRe: Need way to access controls on page from a static method in codebehind. Pin
Not Active25-May-10 17:28
mentorNot Active25-May-10 17:28 
QuestionUpdating contents of GridView from JavaScript Pin
Adam Brown 325-May-10 5:55
Adam Brown 325-May-10 5:55 
AnswerRe: Updating contents of GridView from JavaScript Pin
Viral Upadhyay25-May-10 18:27
Viral Upadhyay25-May-10 18:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.