negative index problem...

Jul 10, 2008
Reaction score
I'm writing on some code related to multilevel nested detail data display on grid view.
something like when u press on + button the detail of the data will show as another grid view...when u press - button they will be hide back.
my code is in vb and sql data source is not allowed.
So i am using stored procedure to set the select query. When test run, after press on + button the child grid view is not showing up.
Can somebody help me please?
Thanks ya..
The below is part of the code:

HTML code:

<asp:GridView ID="gvMAReview" runat="server" AutoGenerateColumns="False" CellPadding="4"
Font-Names="Trebuchet MS" Font-Size="10pt" ForeColor="#333333" GridLines="None"
Width="900px" OnRowEditing= "gvMAReview_RowEditing" >
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<asp:TemplateField HeaderText="No">
<asp:Label ID="Label1" runat="server" Text='<%# Bind("no") %>'></asp:Label>
<asp:TemplateField HeaderText="Part No">
<asp:Label ID="lblPartNo" runat="server" Text='<%# Bind("partNo") %>'></asp:Label>
<asp:TemplateField HeaderText="View">
<asp:Button ID="Label10" runat="server" Text="+" CommandName="Edit"></asp:Button>
<asp:Button ID="TextBox10" runat="server" Text="-" CommandName="Cancel"></asp:Button>
<asp:GridView ID="gvDetailsReview" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" OnRowEditing= "gvDetailsReview_RowEditing" >
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<asp:TemplateField HeaderText="Ordered Quantity">
<asp:Label ID="Label1" runat="server" Text='<%# Bind("orderedQuantity") %>'></asp:Label>
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="White" />

VB Code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then

End If
End Sub

Private Sub LoadMAReview()
Dim ds As DataSet
ds = getReview.GetReviewInfo()
gvMAReview.DataSource = ds
End Sub

Protected Sub gvMAReview_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs)
Dim parent As Integer = Integer.Parse(e.NewEditIndex)
Dim row As GridViewRow = gvMAReview.Rows(parent)
Dim lblPartNo As Label = CType(row.FindControl("lblPartNo"), Label)
Session("PartNo") = lblPartNo.Text
Session("ParentGridViewIndex") = parent
gvMAReview.EditIndex = parent
End Sub
Last edited:


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question