Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Conditional Gridview Edit Column Not Working

Reply
Thread Tools

Conditional Gridview Edit Column Not Working

 
 
Kristen
Guest
Posts: n/a
 
      08-31-2006
I am trying to display an edit column in my gridview based on certain
data conditions. It works fine until I do a post back else where on
the page then the grid is redrawn and the edit column that was absent
is now present. The conditional formating is set up such:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

If Not DataBinder.Eval(e.Row.DataItem, "fee_cost_type_ID")
Is DBNull.Value Then

e.Row.Cells(4).Text = ""
e.Row.Cells(5).Text = ""
End If
End If

End Sub

Here is the gridview:

<asp:GridView ID="GridView1" runat="server"
DataKeyNames="Workout_fac_ID" AutoGenerateColumns="False"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating"
OnRowUpdated="GridView1_RowUpdated"
OnRowDeleting="GridView1_RowDeleting" ShowFooter="True"
OnRowCommand="GridView1_RowCommand" ><Columns>

<asp:TemplateField HeaderText="ID" visible = "false">

<ItemTemplate>

<asp:Label ID="lblRecordID" runat="server" Text='<%#
Bind("Workout_fac_ID") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField >

<ItemTemplate>

</ItemTemplate>

<FooterTemplate>

<asp:Button ID="Btn_Add" runat="server" CommandName="AddFee" Text="Add"
/>

</FooterTemplate>


</asp:TemplateField>

<asp:TemplateField HeaderText="Amount">

<ItemTemplate>

<asp:Label ID="lblFee" Text='<%# Eval("Amount") %>'
runat="server"></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtFee" Text='<%# Eval("Amount") %>'
runat="server"></asp:TextBox>

</EditItemTemplate>

<FooterTemplate>

<asp:TextBox ID="txtAddFee" runat="server"></asp:TextBox>

</FooterTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="Description">

<ItemTemplate>

<asp:Label ID="lblDescription" Text='<%# Eval("Description") %>'
runat="server"></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtDescription" Text='<%# Eval("Description") %>'
runat="server"></asp:TextBox>

</EditItemTemplate>

<FooterTemplate>

<asp:TextBox ID="txtAddDescription" runat="server"></asp:TextBox>

</FooterTemplate>

</asp:TemplateField>

<asp:CommandField HeaderText="Edit" ShowEditButton="True" />

<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />

</Columns>

</asp:GridView>

Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
GridView control enters edit mode when I click Edit link twice Jaime Stuardo ASP .Net Web Controls 0 04-07-2006 12:47 AM
GridView edit validation, edit dropdown list, delete popup confirm =?Utf-8?B?a2Vu?= ASP .Net 1 01-23-2006 12:51 PM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM



Advertisments