Please provide the steps to load the text boxes on the form with the details of the
first record out of the search.
stored procedure
ALTER PROCEDURE [dbo].[sp_SearchActLoan]
(
@searchString varchar(500)
)
AS
BEGIN
IF @searchString <> ''
BEGIN
CREATE TABLE #SearchResults
(
Zidno varchar(20),
Zid_Code varchar(20),
Zapprs_No varchar(20),
ZCustomer varchar(60),
Zint_No varchar(10),
Zint_Name varchar(50),
Zloanumber varchar (20)
)
Insert Into #SearchResults(Zidno,Zid_Code,Zapprs_No,ZCustomer,Zint_No,Zint_Name,Zloanumber)
Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME,LOANUMBER From LOANS
Where IDNO Like '%' + @searchString + '%'
Union
Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME,LOANUMBER From LOANS
Where ID_CODE Like '%' + @searchString + '%'
Union
Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME,LOANUMBER From LOANS
Where APPRS_NO Like '%' + @searchString + '%'
Union
Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME,LOANUMBER From LOANS
Where CUSTOMER Like '%' + @searchString + '%'
Select Zidno 'ACTUAL LOAN ID' ,
Zid_Code 'CUSTOMER ID' ,
Zapprs_No 'APPRAISAL NO',
ZCustomer 'NAME',
Zint_No 'INT_CODE',
Zint_Name 'INT_NAME',
Zloanumber 'LOANUMBER'
From #SearchResults order by Zidno,Zloanumber
END
There are more controls on the form than the feeder into the grid
Please provide the necessary codes to populate the form with all the fields necessary to complete the form.
I am only able to get the output from the grid only on selection.
So after a search the form is not updated with the output in the grid.
Thanks
Added code from replies:
public void LoadSearch()
{
try
{
SqlConnection connect = new SqlConnection();
connect.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
connect.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM LOANS order by LOANUMBER, IDNO", connect);
SqlCommand SqlCmd = new SqlCommand("sp_searchActLoan", connect);
SqlCmd.CommandType = CommandType.StoredProcedure;
SqlCmd.Parameters.AddWithValue("@searchString", txt_Search.Text);
SqlCmd.ExecuteNonQuery();
SqlDataAdapter daa = new SqlDataAdapter();
daa.SelectCommand = SqlCmd;
DataSet dsas = new DataSet();
daa.Fill(dsas, "searchResults");
GridView1.DataSource = dsas;
GridView1.DataBind();
connect.Close();
GridView1.Visible = true;
}
catch (Exception ex)
{
lblStatus.Text = ex.Message;
}
}
protected void btn_Go_Click(object sender, EventArgs e)
{
if (txt_Search.Text != "")
LoadSearch();
}