By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

appending editable column in grid view

P: 28
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 Images
File Type: jpg grid.jpg (14.4 KB, 458 views)
Apr 6 '09 #1
Share this Question
Share on Google+
2 Replies


BeemerBiker
P: 87
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.
Apr 6 '09 #2

P: 28
Yes thats a great idea it really worked...
I used this in aspx...
<Columns>
<asp:templatefield HeaderText="Attenedence" >
<itemtemplate>
<asp:textbox id="tbFoo" runat="server" />
</itemtemplate>
</asp:templatefield>
</Columns>

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

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
TextBox tb = (TextBox)e.Row.FindControl("tbFoo");
}
}


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

Thanks a lot for your idea...Glad to receive your post...
Apr 7 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.