473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

limit what the gridview shows based on what is searched for

I have a gridview that is bound to a database. I also have fields where you can search for something and then it show up in the gridview based on what you searched for. ex, you can search for pro that starts with 123 and everything that starts with those numbers will come up. I also have a field called invoice number. however, i want to only allow it to show in the gridview if it is searched for. right now this is my code for the gridview.

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" PageIndex="0" EnableSortingAndPagingCallbacks="True" CssClass="GridView" AllowPaging="false" PageSize="30" AllowSorting="true" OnSorting="gvFreightBills_Sorting" runat="server" CellPadding="1" CellSpacing="2" GridLines="Vertical" HorizontalAlign="Left" AutoGenerateColumns="false" RowStyle-Height="19" DataKeyNames="DATE_ENT,CARRIER,PRO">
  2.  
  3.  
  4.                     <AlternatingRowStyle BackColor="#CCCCCC" />
  5.                     <Columns>
  6.                         <asp:CommandField ControlStyle-CssClass="GridViewSelectButton" HeaderStyle-Width="40" ItemStyle-Width="40" SelectText="Select" ShowSelectButton="true" ItemStyle-HorizontalAlign="center"></asp:CommandField>
  7.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="SHIP_DATE" HeaderText="Ship Date" ControlStyle-Width="70" HeaderStyle-Width="70" ItemStyle-Width="70" SortExpression="tbl_Bills.[Date]" DataFormatString="{0:d}"></asp:BoundField>
  8.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="DATE_ENT" HeaderText="Date Ent." ControlStyle-Width="70" HeaderStyle-Width="70" ItemStyle-Width="70" SortExpression="tbl_Bills.[DATE ENT]" DataFormatString="{0:d}"></asp:BoundField>
  9.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="CARRIER" HeaderText="Carrier" ReadOnly="True" SortExpression="CARRIER" HeaderStyle-Width="50" ItemStyle-Width="50"></asp:BoundField>
  10.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="PRO" HeaderText="PRO" ControlStyle-Width="105" HeaderStyle-Width="105" ReadOnly="True" SortExpression="PRO"></asp:BoundField>
  11.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="spec_fedinv" HeaderText="Invoice No" SortExpression="tbl_bills.[spec_fedinv]"></asp:BoundField>
  12.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="SHIPPER" HeaderText="Shipper" ControlStyle-Width="50" HeaderStyle-Width="70" ItemStyle-Width="70" SortExpression="SHIPPER" ></asp:BoundField>
  13.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="CONS" HeaderText="Consignee" SortExpression="CONS" ControlStyle-Width="70" HeaderStyle-Width="70" ItemStyle-Width="70"></asp:BoundField>
  14.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="F_B" HeaderText="BOL No" SortExpression="F_B"></asp:BoundField>
  15.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="LOC" HeaderText="Loc" SortExpression="LOC"></asp:BoundField>
  16.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="PCS" HeaderText="PCS" SortExpression="PCS" ControlStyle-Width="30" HeaderStyle-Width="30" ItemStyle-Width="30"></asp:BoundField>
  17.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="WT" HeaderText="WT" SortExpression="WT" ControlStyle-Width="30" HeaderStyle-Width="30" ItemStyle-Width="30"></asp:BoundField>
  18.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="NET_CHGS" HeaderText="NET Chgs." ControlStyle-Width="60" HeaderStyle-Width="60" ItemStyle-Width="60" SortExpression="NET_CHGS" DataFormatString="{0:$0.00}"></asp:BoundField>
  19.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="DATE_PAID" HeaderText="Date Paid" ControlStyle-Width="70" HeaderStyle-Width="70" ItemStyle-Width="70" SortExpression="tbl_Bills.[DATE PAID]" DataFormatString="{0:d}"></asp:BoundField>
  20.                         <asp:BoundField ItemStyle-CssClass="GVCol" DataField="CK_NO" HeaderText="CK No." SortExpression="tbl_Bills.[CK NO]"></asp:BoundField>
  21.                     </Columns>
  22.                     <FooterStyle BackColor="#CCCCCC" />
  23.                     <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
  24.                     <RowStyle Height="19px"></RowStyle>
  25.                     <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
  26.                 </asp:GridView>
this is what i have for my textboxes
Expand|Select|Wrap|Line Numbers
  1. <div class="Spacer5"></div>
  2.             <div class="Dotted40"></div>
  3.             <div class="Spacer5"></div>
  4.  
  5.                 <div class="divFBQueryLineItemWrapper">
  6.                     <div class="divFBQueryLeftColumn">
  7.                         Pro: 
  8.                     </div>
  9.                     <div class="divFBQueryRightColumn">
  10.                         <asp:TextBox ID="tbProNumber" Width="115px" runat="server"></asp:TextBox>
  11.  
  12.                     </div>
  13.                     <div style="clear: both"></div>
  14.                 </div>
  15.  
  16.  
  17.                 <div class="Spacer5"></div>
  18.                 <div class="divFBQueryLineItemWrapper">
  19.                     <div class="divFBQueryLeftColumn">
  20.                         Invoice No: 
  21.                     </div>
  22.                     <div class="divFBQueryRightColumn">
  23.                         <asp:TextBox ID="tbInvoiceNo" Width="115px" runat="server"></asp:TextBox>
  24.  
  25.                     </div>
  26.                     <div style="clear: both"></div>
  27.                 </div>
  28.  
  29.                 <div class="Spacer5"></div>
  30.                 <div class="divFBQueryLineItemWrapper">
  31.                     <div class="divFBQueryLeftColumn">
  32.                         Bill of Lading: 
  33.                     </div>
  34.                     <div class="divFBQueryRightColumn">
  35.                         <asp:TextBox ID="tbBillOfLadingNumber" Width="115px" runat="server"></asp:TextBox>
  36.  
  37.                     </div>
  38.                     <div style="clear: both"></div>
i also have a search button. I think that i would put something in my search button click event that says if tbinvoice is blank then do not show the row for invoice in the gridview, else show it. but how i would i code that? please help!
Oct 6 '15 #1

✓ answered by lillyehrhart

here is my solution
Expand|Select|Wrap|Line Numbers
  1. If tbInvoiceNo.Text = "" Then
  2.             GridView1.Columns(5).Visible = False
  3.         Else
  4.             GridView1.Columns(5).Visible = True
  5.         End If

3 1568
nevermind i figured it out.
Oct 6 '15 #2
Rabbit
12,516 Expert Mod 8TB
Could you post your solution in case someone runs into the same issue?
Oct 6 '15 #3
here is my solution
Expand|Select|Wrap|Line Numbers
  1. If tbInvoiceNo.Text = "" Then
  2.             GridView1.Columns(5).Visible = False
  3.         Else
  4.             GridView1.Columns(5).Visible = True
  5.         End If
Oct 8 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Not Me | last post by:
Hi, It it possible to alter properties of a gridview control based on the data it holds? Specifically, I would like to alter colours held in the data. For example....here's the data ...
4
by: P. Yanzick | last post by:
Hello, I've been playing with master/detail views as well as editing in the gridview, and I ran across a strange problem that I am not exactly sure where to go to try to solve. I have 2...
1
by: Jay Pondy | last post by:
I have a datasource with 2 columns PKID and Description. The datasource is bound to a sortable GridView where the PKID field is NOT visible. If the user has a row selected before the grid is...
1
by: aabruzzese | last post by:
Hi folks, Been struggling with this little puzzle. I am reading the MemberInfo table for the ClubStarterKit, the table includes the Avatar for the User. I would like to display the Avatar...
2
by: Pradeep | last post by:
hi, im having a very peculiar problem. I populate the gridview based on the result of a query, and the gridview shows the rows that are returned by the query. now if i give gridview1.rows.count i...
0
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i...
0
by: mattd1 | last post by:
I'm using VS2008, and I need to put a gridview into a table cell (an asp table). I made the gridview and set it all up outside the table, then I edit the HTML and move the gridview into the table...
2
by: =?Utf-8?B?SHV0dHk=?= | last post by:
I have searched the net but have been unable to find a solution to subtotaling in a gridview. I have a gridview that is bounded to sqldatasource where I would like to subtotal rows throughout the...
1
anoble1
by: anoble1 | last post by:
Hi, I am making what I thought would be simple project. I want to be able to type a product in, and search our knowledgebase. Before: http://southernco.custhelp.com/app/answers/list/kw/ ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.