[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]
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
Re: Bound Unbound gridview problem
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
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='<%# 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.
Re: [RESOLVED] Bound Unbound gridview problem
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.