CEREBRUS, many thanks for your response.

Yes, I'm actually editing/deleting my data. But it doesn't show in gridview
control, until I manually refresh the page.

Here is some code (I'm using a SQLite membership/role/profile provider, and
I'm updating/removing users here):

 

My gridview in the aspx file:

 

<asp:GridView ID="GridView1" runat="server">

        <Columns>

            <asp:CommandField ButtonType="Button" ShowEditButton="True" />

            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" />

        </Columns>

</asp:GridView>

 

 

My codefile:

 

private ArrayList arrusernames = new ArrayList();

 

protected void Page_Load(object sender, EventArgs e)

        {

            SQLiteConnection conn = new SQLiteConnection();

            conn.ConnectionString =
ConfigurationManager.ConnectionStrings["SQLiteDbConnection"].ToString();

            conn.Open();

            SQLiteCommand cmd = new SQLiteCommand("SELECT aspnet_Users.*
FROM aspnet_Users WHERE IsApproved = 1 ORDER BY CreateDate DESC", conn);

 

            SQLiteDataReader reader;

 

            reader = cmd.ExecuteReader();

 

            if (reader.HasRows)

            {

                while (reader.Read())

                {

                    arrusernames.Add(reader.GetString(1));

                }

            }

            conn.Close();

 

            DataTable dt = new DataTable("ActiveUsers");

            dt.Columns.Add("First Name", typeof(string));

            dt.Columns.Add("Last Name", typeof(string));

            //dt.Columns.Add("Options");

 

            foreach (string item in arrusernames)

            {

                ProfileBase profileUser = ProfileBase.Create(item);

                string firstname =
profileUser.GetPropertyValue("FirstName").ToString();

                string lastname =
profileUser.GetPropertyValue("LastName").ToString();

 

                DataRow newrow = dt.NewRow();

                newrow[0] = firstname;

                newrow[1] = lastname;

 

                dt.Rows.Add(newrow);

 

            }

 

            DataSet dataset = new DataSet("dsActiveUsers");

            dataset.Tables.Add(dt);

 

            GridView1.DataSource = dataset;

            GridView1.DataBind();

 

            GridView1.RowEditing += new
GridViewEditEventHandler(handleGridViewEdit);

            GridView1.RowDeleting += new
GridViewDeleteEventHandler(handleGridViewDelete);

            GridView1.RowDeleted += new
GridViewDeletedEventHandler(handleGridViewDeleted);

 

        }

 

//Deleting Users here:

private void handleGridViewDelete(object sender, GridViewDeleteEventArgs e)

        {

            object[] arrusers = arrusernames.ToArray();

            Membership.DeleteUser(arrusers[e.RowIndex].ToString());

            GridView1.Databind();//Also tried in the RowDeleted event

        }

 

 

 

 

_________________________________

Claudio M. E. Bastos Iorio

http://www.blumersolutions.com

 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Cerebrus
Sent: Saturday, April 11, 2009 5:39 AM
To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting
Subject: [DotNetDevelopment] Re: gridview.databind doesn't work

 

 

Can you confirm that the data is deleted/modified within the dataset

itself when you delete/edit via the GridView ? Also, I think we need

to see some code here.

 

On Apr 11, 12:54 pm, "Claudio M. E. Bastos Iorio"

<[email protected]> wrote:

> Hi, hope you guys can help me on this one.

> 

> I have a gridview control, the data for this control comes from a dataset,

> created programmatically.

> 

> I also have a delete an a edit button for each record.

> 

> I can edit and delete records (also programatically), but the data is not

> refreshed on the gridview control.

> 

> I tried the method gridview.databind() in the RowDeleting, RowDeleted

> events, in the postback (using IsPostback) and the data is never updated
in

> the gridview.

> 

> Any idea?

> 

> TIA

> 

> _________________________________

> 

> Claudio M. E. Bastos Iorio

> 

>  <http://www.blumersolutions.com/>http://www.blumersolutions.com

Reply via email to