appending editable column in grid view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinod allapu
    New Member
    • Apr 2009
    • 28

    appending editable column in grid view

    Hi all,

    i want to append an empty column to the grid view. Only the appended column should be editable and while displaying the grid the entire column should be in editable mode(not a single cell) . so that the user can enter values in that column and update. My grid should not contain any edit,update buttons.
    Please check the image for better understanding.

    Is it possible to do like this...
    Thanking you all,
    Attached Files
  • BeemerBiker
    New Member
    • Jul 2008
    • 87

    #2
    I think it is safer to use that update button especially since you are updating multiple records, not just changing a lot of stuff in one record.

    However, to answer your questions, I had the following scheme that "worked for me"

    I added an unbound column (template of DropDownList) to my gridview at design time with "enabled" and readonly to false (think these are defaults). When the page first loaded I filled in the columns with what I wanted. When the page next loaded (IsPostBack is true) I then checked to see if any of the cells in the column changed. If a change then I added it to an ArrayList and stored the array list in the Session variable. If the postback was caused by the Submit button, then when that button's event handler was fired I processed the ArrayList items, updated the database and refreshed the page.

    There may be a lot easier ways to do this but since the defaults on my page load was all "blank fields" then it was easy for me to detect any change and I set AutoPostBack to false on the DropDownList because I wanted my submit button to handle all updates.

    Comment

    • vinod allapu
      New Member
      • Apr 2009
      • 28

      #3
      Yes thats a great idea it really worked...
      I used this in aspx...
      <Columns>
      <asp:templatefi eld HeaderText="Att enedence" >
      <itemtemplate >
      <asp:textbox id="tbFoo" runat="server" />
      </itemtemplate>
      </asp:templatefie ld>
      </Columns>

      and in .cs fike I used this It really done a wonderful job for me..

      protected void GridView1_RowDa taBound(object sender, GridViewRowEven tArgs e)
      {
      if(e.Row.RowTyp e == DataControlRowT ype.DataRow)
      {
      TextBox tb = (TextBox)e.Row. FindControl("tb Foo");
      }
      }


      protected void btnUpdate_Click (object sender, EventArgs e)
      {
      for (int i = 0; i < GridView1.Rows. Count; i++)
      {
      TextBox tb = (TextBox)GridVi ew1.Rows[i].Cells[0].FindControl("t bFoo");

      Thanks a lot for your idea...Glad to receive your post...

      Comment

      Working...