Garima Bansal

Garima Bansal

  • 1.1k
  • 676
  • 39.4k

Search data from database

Mar 10 2023 7:06 AM

I want search a Id for example:

In database table  i have GId like 1AGR2023 and want to search using textbox, if id is incorrect or not in database then message shown otherwise Details of related GId like (Name, Contact,Remarks,Status) fill in gridview.

<div class="row mb-3">
    <label for="inputText" class="col-sm-4 col-form-label">Enter your Id.:</label>
    <div class="col-sm-8">
        <asp:TextBox runat="server" ID="txtid" CssClass="form-control" MaxLength="9"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="form-control" ErrorMessage="**" ControlToValidate="txtid" ForeColor="Red"></asp:RequiredFieldValidator>
    </div>
</div>

<div class="row m-4 mt-5">
    <center>
        <asp:Button runat="server" ID="btn_Submit" CssClass="col-sm-3 btn btn-success" Text="Search" OnClick="btn_Submit_Click" />
</div>

<asp:GridView ID="grdtrack" runat="server" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" Visible="false">
    <Columns>
        <asp:BoundField HeaderText="Id" DataField="Id" Visible="false" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Name" HeaderText="Name" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Mobile_No" HeaderText="Mobile No" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Details" HeaderText="Remarks" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Status" HeaderText="Status" />

    </Columns>
</asp:GridView>

 


Answers (2)