Edit GridView without template control


 I have a gridview but need to bulk edit the gridview via a event from a button.  Not sure how to go about doing that.  Any examples or ideas? 
Thanks,
0
Jarhead88
12/4/2008 10:00:10 PM
📁 asp.net.presentation-controls
📃 72751 articles.
⭐ 3 followers.

💬 6 Replies
👁️‍🗨️ 784 Views



 http://www.gridviewguy.com/ArticleDetails.aspx?articleID=219_GridView_All_Rows_in_Edit_Mode

Give a man a fish and you feed him for a day.  Teach a man to fish and you feed him forever.
0
ramireddyindia
12/5/2008 3:59:12 AM

 Yeah I tried that or something similar and could not get it to work.  When it binds back to the grid its empty and not a textbox. 
0
Jarhead88
12/5/2008 9:37:04 PM

 can you show us the code what you tried? so that we will do necessary modifications.

Give a man a fish and you feed him for a day.  Teach a man to fish and you feed him forever.
0
ramireddyindia
12/6/2008 3:40:24 AM

Here is the code behind.  the html code is same as article just name differently.  It hits the edit fine but when rebinding it never chgs it to text box.  
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            User usr = ((IRISPage)this.Page).UserObj;
            GroupInfo group = new GroupInfo("OISAPP");
            if (group.IsMember("tktdet", usr.UserName))
            {
                BindData();
            }
            else
            {
                form1.Visible = false;
                //NotAuthorized.Visible = true;
            }
        }
    }
    //Edit button
    protected void btnedit_Click1(object sender, EventArgs e)
    {
        this._visible = true;
        
        
        BindData();
        //GridView1.DataBind();
    }
    //Update button
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < GridView1.Rows.Count; i++)
        GridView1.UpdateRow(i, true);
        _visible = false;
        GridView1.DataBind();
            
    }
0
Jarhead88
12/6/2008 5:48:44 AM

 And here is the Bind method just in case your needing it. 
  protected void BindData()
    {
        DataTable tempTable1 = objConnClass.FillGrid(lblDate.Text, lblDate2.Text, txtEventID.Text, strb.ToString());
        if (tempTable1 != null)
        {
            GridView1.DataSource = tempTable1;
            GridView1.DataBind();
        }
    }
0
Jarhead88
12/6/2008 5:51:43 AM

Hi Jarhead88,
In btnUpdate_Click1 event you also need to set data source to GridView1. It will not display any data to only call DataBind() method for GridView, if the data source is customized such as DataTable.
Thanks,

Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Qin
12/9/2008 8:36:20 AM
Reply: