negative index problem...


Joined
Jul 10, 2008
Messages
1
Reaction score
0
Hi,
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" />
<Columns>
<asp:TemplateField HeaderText="No">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("no") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part No">
<ItemTemplate>
<asp:Label ID="lblPartNo" runat="server" Text='<%# Bind("partNo") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:Button ID="Label10" runat="server" Text="+" CommandName="Edit"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<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" />
<Columns>
<asp:TemplateField HeaderText="Ordered Quantity">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("orderedQuantity") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<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" />
</asp:GridView>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<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" />
</asp:GridView>


VB Code:


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

LoadMAReview()
End If
End Sub

Private Sub LoadMAReview()
Dim ds As DataSet
ds = getReview.GetReviewInfo()
gvMAReview.DataSource = ds
gvMAReview.DataBind()
ds.Clear()
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
gvMAReview.DataBind()
End Sub
 
Last edited:
Ad

Advertisements


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

Top