James-
When you query out an object using LINQ and then update it, you must submit
it back to the data source.
I'm assuming your LinkButton1_Command is what is toggling your IsActiveEmployee
(IsPrivateContact?).
[quoted text, click to view] > public static void MarkPrivate(int cid)
> {
> var ContactList = (from contacts in
> GlobalListOfOutLookContacts where (contacts.ContactId == cid) select
> contacts).First();
> ContactList.IsPrivateContact = true;
> }
After you update your ContactList object here, add in:
TheNameOfYourDataContextObject.SubmitChanges(); // If you've build your
own Update method, you could fire that off instead.
gridview1.DataBind(); // To rebind your data to the updated data source.
HTH.
-dl
--
David R. Longnecker
http://blog.tiredstudent.com [quoted text, click to view] > I've got a GridView control on a simple web page in ASP.net 3.5.
>
> I've an Array of Employees. An Employee has First Name, Last Name,
> IsActiveEmployee etc
>
> My GridView control is Bounded to the Array: DataSource = myarray,
> gridview1.DataBind()
>
> I have template column with holds a link button
>
> when the button is clicked, I've got a method which will set the
> selected
>
> employee "IsActiveEmployee" flag to false.
>
> My problem is that when the page reloads and binds, the array returned
> is NOT change - it is the same array.
>
> Can somebody please help?
>
> My Page file is defined as:
>
> public partial class _Default : System.Web.UI.Page {
>
> protected void Page_Load(object sender, EventArgs e)
> {
> this.GridView1.DataSource =
> Utils.GetGlobalListOfOutlookContacts();
> this.GridView1.DataBind();
> }
> protected void MarkAsPrivate(int id)
> {
> int tmpId = id;
> Utils.MarkPrivate(tmpId);
> }
> protected void LinkButton1_Command(object sender, CommandEventArgs e)
> {
> object o = e.CommandArgument;
> String s = Convert.ToString(o);
> int tmpId = Convert.ToInt32(s);
> Utils.MarkPrivate(tmpId);
> }
> }
>
> My Utils file is defined as:
>
> public static class Utils
> {
> public static readonly String SPACE = " ";
> private static List<AContact> GlobalListOfOutLookContacts =
> new List<AContact>()
> {
> new AContact {ContactId=1388, FirstName = "Kriss",
> LastName = "Bellamy", Company="Oracle",
> E_mail="kriss.bellamy@oracle.com", Location="5100 Town Cntr Circle"},
> new AContact {ContactId=1389, FirstName = "Ada", LastName
> = "peterson", Company="Oracle", E_mail="ada.peterson@oracle.com",
> Location="1364 Park Street"},
> new AContact {ContactId=1390, FirstName = "Paul", LastName
> = "wellby", Company="Oracle", E_mail="paul.wellby@oracle.com",
> Location="54 State St Suite 1000"},
> new AContact {ContactId=1391, FirstName = "Damien",
> LastName = "Johnson", Company="Google",
> E_mail="damien.johnson@oracle.com", Location="1 Atlon Court Paris"}
> };
> public static List<AContact> GetGlobalListOfOutlookContacts()
> {
> var ContactList = from contacts in
> GlobalListOfOutLookContacts where contacts.IsPrivateContact != true
> select contacts;
> List<AContact> retVal = new List<AContact>();
> foreach (AContact c in ContactList)
> {
> retVal.Add(c);
> }
> return retVal;
> }
> public static void MarkPrivate(int cid)
> {
> var ContactList = (from contacts in
> GlobalListOfOutLookContacts where (contacts.ContactId == cid) select
> contacts).First();
> ContactList.IsPrivateContact = true;
> }
>