Results 1 to 7 of 7

Thread: [RESOLVED] Bound Unbound gridview problem

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    45

    Resolved [RESOLVED] Bound Unbound gridview problem

    Hii
    I have a gridview in which 4 columns are bound and 2 unbound.
    Iam using VS2005 with vb.net

    HTML Code:
    Q1) How to get the unbound columns at the end of bound columns. (currently unbound columns are coming first)
    
    Q2) How to show the value of difference of two bound columns in unbound column.
    e.g) 
    TotalQty  QtyOrdered   Balance
    10          4               6
    15          8               7
    
    Q3) How to put condition in gridview column.
    e.g) 
    TotalQty  QtyOrdered   Balance   Order
    10          4               6          
    15          8               7
    
    if i put 8 in order column of first row it shows message that you cannot order more than total quantity
    
    Balance and Order are unbound columns.[QUOTE][/QUOTE]
    Last edited by sandy15981; Jan 3rd, 2010 at 11:14 AM.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Bound Unbound gridview problem

    Hey,

    I am not sure that I follow exactly what you are getting at.

    Can you show the code that you are currently using? Both the ASPX markup, and any server side code?

    Gary

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    45

    Re: Bound Unbound gridview problem

    Thanks
    Problem solved

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Bound Unbound gridview problem

    Hey,

    For the benefit of other people in the forum, perhaps with a similar issue, it would be good if you can post the solution that you came up with.

    Also, if you have solved your problem, remember to mark your thread as resolved.

    Gary

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    45

    Re: Bound Unbound gridview problem

    Code:
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                            AutoGenerateDeleteButton="True" DataSourceID="SqlDataSource2">
                            <Columns>
                                <asp:TemplateField HeaderText="ItemID" SortExpression="ItemID">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox3" runat="server" Text='<&#37;# Bind("ItemID") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("ItemID") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="MatName" HeaderText="MatName" SortExpression="MatName" />
                                <asp:BoundField DataField="Qty" HeaderText="Qty" SortExpression="Qty" />
                                <asp:BoundField DataField="QtyOrdered" HeaderText="QtyOrdered" SortExpression="QtyOrdered" />
                                <asp:BoundField DataField="Balance" HeaderText="Balance" ReadOnly="True" SortExpression="Balance" />
                                <asp:TemplateField HeaderText="QtyOrder" SortExpression="QtyOrder">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("QtyOrder") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:TextBox ID="TextBox4" runat="server" Width="66px"></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Price" SortExpression="Price">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:TextBox ID="TextBox5" runat="server" Width="79px"></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Admin_EstimateConnectionString2 %>"
                            DeleteCommand="DELETE FROM PODetails WHERE (ItemID = @ItemID)" SelectCommand="SELECT PODetails.ItemID, EstMaterials.MatName, EstMaterials.Qty, EstMaterials.QtyOrdered, EstMaterials.Qty - EstMaterials.QtyOrdered AS Balance, PODetails.Qty AS QtyOrder, PODetails.Price FROM EstMaterials INNER JOIN PODetails ON EstMaterials.MatID = PODetails.ItemID"
                            UpdateCommand="UPDATE PODetails SET [Qty] = @Qty, [Price] = @Price">
                            <DeleteParameters>
                                <asp:Parameter Name="ItemID" Type ="Int32" />
                            </DeleteParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="Qty" Type ="Decimal" />
                                <asp:Parameter Name="Price" Type ="Decimal" />
                            </UpdateParameters>
                        </asp:SqlDataSource>
    My First 2 problems are solved by above code.
    I still want solution for third.

  6. #6

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] Bound Unbound gridview problem

    Place a RangeValidator next to your textbox in your templatefield in your gridview; and assign it to the textbox. Set its range to a maximum of 8. If the user enters something higher than 8, it should prevent the form from submitting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width