Hi,
I am wondering if anyone can help me with a small problem I am having. I am populating a gridview from an oracle DB. I only want some of these columns to be editable so I am using the code below to try and acheive this. As you can see I only 3 of the 4 columns to be allowed to be edited. However, the strange problem I am getting is that the only row that will open for edit is the one I wish to stay closed, while the other 3 are remaining closed! I think I am just doing something stupid here, but I really cant see it. Also, the page seems to be loading slower than I would have thought it would. I am presuming this is because I am binding the grid for a 2nd time whenever I press edit. Are there any easier ways of doing this?
Kindest Regards
David.
<code>
<asp:GridView ID="GridView1" BackColor="#f1f1f1"
AutoGenerateColumns="false" DataKeyNames="category_code" ShowFooter="true"
Font-Size="Small" Font-Names="Verdana" runat="server" GridLines="None"
OnRowDataBound="GridView1_RowDataBound" OnRowEditing ="GridView1_RowEditing" BorderStyle="Outset" >
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White"/>
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:expandcollapse('div<%# Eval("category_code") %>', 'one');">
<img id="imgdiv<%# Eval("category_code") %>" alt="Click to show/hide Orders for Customer <%# Eval("category_code") %>" width="9px" border="0" src="Images/plus.gif"/>
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField ="category_code" headertext="Category Code" HeaderStyle-HorizontalAlign ="Left" />
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDescription" Text='<%# Eval("description") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblDescription" Text='<%# Eval("description") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget Amt">
<ItemTemplate>
<asp:Label ID="lblBudgetAmt" Text='<%# Eval("budget_amt") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblBudgetAmt" Text='<%# Eval("budget_amt") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Payment Freq" >
<ItemTemplate>
<asp:Label ID="lblPayfreq" Text='<%# Eval("pay_freq") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblPayfreq" Text='<%# Eval("pay_freq") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="" ShowEditButton="true" />
.....
</code>
here is my VB code
<code>
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
Dim Al As New ArrayList
Dim Dt As New DataSet()
GridView1.EditIndex = CInt(e.NewEditIndex)
Al.Add(ReturnDbParam("pc_cu_id", "Test"))
Al.Add(ReturnDbParam("pc_member_id", "test"))
Dt = GetDataset(Al, "pkdb_web_budgets.f_get_categories", "budgets")
Me.GridView1.DataSource = Dt.Tables("budgets")
Me.GridView1.DataBind()
End Sub
</code>