468,117 Members | 1,472 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

Grid view Edit Item Template column not visible.

I have a grid which i bind with values from Database. I have events to edit and update the grid. I am not using SqlDatasource to connect to DB. Rather i am doing the updating of the grid Programmatically.

I have 3 columns, LID(item template column) ,LVal (Edit Item template column) and Edit link

My Question:
1) My EditITemTemplate column has a textbox txt_Lval which does not show up on the page load. But if click on edit link that particular row alone shows that edit item template column which has been invisible. I cannot see the column in design view itself. But if i change that to an Item template column it shows up in edit mode. I want to show it in edit mode only after user clicks Edit link

I have no idea what is going on with that invisible edit item template column which suddenly shows up during edit. The user should be able to see LVal column.

I am able to edit and update the row and insert the updated values back into DB.

Thank you for your help in Advance.

My grid details:-
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID = "gvLv" runat = "server" AutoGenerateColumns = "False" DataKeyNames = "LID" 
  2. CellPadding="4" ForeColor="#333333" GridLines="None" OnRowEditing = "gvLv_RowEditing" OnRowUpdating = "gvLv_RowUpdating" > 
  3. <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  4. <RowStyle BackColor="#EFF3FB" />
  5. <Columns> 
  6. <asp:TemplateField HeaderText="LID" SortExpression="LID">
  7. <ItemTemplate>
  8. <asp:Label ID="lbl_Lid" runat="server" Text='<%# Bind("LID") %>'></asp:Label> 
  9. </ItemTemplate>
  10. </asp:TemplateField>
  11. <asp:TemplateField HeaderText="Lval" Visible ="true" SortExpression="Lval">
  12. <EditItemTemplate>
  13. <asp:TextBox ID="txt_Lval" runat="server" Text='<%# Bind("LVAL") %>' Visible = "true"></asp:TextBox>
  14. </EditItemTemplate>
  15. </asp:TemplateField>
  16. <asp:CommandField ShowEditButton="True" />
  17. </Columns> 
  18. <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  19. <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  20. <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  21. <EditRowStyle BackColor="#2461BF" />
  22. <AlternatingRowStyle BackColor="White" />
  23. </asp:GridView>
My Events looks like this:-
Expand|Select|Wrap|Line Numbers
  1. Protected Sub gvLv_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles gvLv.RowCancelingEdit
  2. gvLv.EditIndex = -1
  3. LoadGrid()
  4. End Sub
  5.  
  6. Protected Sub gvLv_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvLv.RowEditing
  7. gvLv.EditIndex = e.NewEditIndex()
  8. LoadGrid()
  9. End Sub
  10.  
  11. Protected Sub gvLv_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvLv.RowUpdating
  12. rowlid = CType(gvLv.Rows(e.RowIndex).FindControl("lbl_Lid"), Label).Text
  13. rowval = CType(gvLv.Rows(e.RowIndex).FindControl("txt_Lval"), TextBox).Text
  14. oCAD.UpdateList(CType(rowlid, Int32), rowval)
  15. LoadGrid()
  16. End Sub
Jul 28 '08 #1
1 5829
Frinavale
9,735 Expert Mod 8TB
The Edit Item Template only appears when the user is Editing that row....
Therefore, the user must click the edit button before this becomes available to them.

You should look into using the ItemTemplate to accomplish what you are attempting to implement.

-Frinny
Jul 28 '08 #2

Post your reply

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

Similar topics

3 posts views Thread by Simon Harris | last post: by
1 post views Thread by Chris | last post: by
1 post views Thread by Mad Scientist Jr | last post: by
2 posts views Thread by Joe Griffith | last post: by
2 posts views Thread by Smokey Grindle | last post: by
2 posts views Thread by puja | last post: by
2 posts views Thread by =?Utf-8?B?Z2FuZQ==?= | last post: by
reply views Thread by =?Utf-8?B?VGVjaGVlaw==?= | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.