I have the following codes which have to fill the text boxes on the form however only one text box
is filled on pressing the select button.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string str;
str = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
SqlConnection sqlcon = new SqlConnection(str);
string intno;
intno = GridView1.SelectedRow.Cells[1].Text;
SqlCommand SqlCmd = new SqlCommand("sp_Getloanid", sqlcon);
SqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
SqlCmd.Parameters.AddWithValue("@INTNO", intno);
SqlCmd.Parameters.Add("@INTNAME", System.Data.SqlDbType.VarChar, 50);
SqlCmd.Parameters["@INTNAME"].Direction = System.Data.ParameterDirection.Output;
SqlCmd.Parameters.Add("@CONTACT", System.Data.SqlDbType.VarChar, 50);
SqlCmd.Parameters["@CONTACT"].Direction = System.Data.ParameterDirection.Output;
SqlCmd.Parameters.Add("@INTSHORTCODE", System.Data.SqlDbType.VarChar, 50);
SqlCmd.Parameters["@INTSHORTCODE"].Direction = System.Data.ParameterDirection.Output;
SqlCmd.Parameters.Add("@INTDATE", System.Data.SqlDbType.DateTime, 15);
SqlCmd.Parameters["@INTDATE"].Direction = System.Data.ParameterDirection.Output;
SqlCmd.Parameters.Add("@INTRATE", System.Data.SqlDbType.VarChar, 50);
SqlCmd.Parameters["@INTRATE"].Direction = System.Data.ParameterDirection.Output;
sqlcon.Open();
SqlCmd.ExecuteNonQuery();
txt_Int_Code.Text = SqlCmd.Parameters["@INTNO"].Value.ToString();
txt_Int_Name.Text = SqlCmd.Parameters["@INTNAME"].Value.ToString();
txt_Short_Name.Text = SqlCmd.Parameters["@INTSHORTCODE"].Value.ToString();
txt_contact.Text = SqlCmd.Parameters["@CONTACT"].Value.ToString();
txt_Int_Dates.Text = SqlCmd.Parameters["@INTDATE"].Value.ToString();
txt_Rates.Text = SqlCmd.Parameters["@INTRATE"].Value.ToString();
lblstatus.Text = "Grid record successful";
sqlcon.Close();
}
catch (Exception ex)
{
lblstatus.Text = ex.Message;
}
}
**************************************************
store procedure
**************************************************
USE [Credit_App]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter Procedure [dbo].[sp_Getloanid]
(
@IntNo varchar(20),
@IntName varchar(50) output ,
@Contact varchar(50) output ,
@IntShortCode varchar(10)output ,
@IntDate DateTime output,
@IntRate money output
)
AS
Begin
Begin
Update INTEREST
Set INT_NAME = @IntName,INT_SHORT = @IntShortCode,INT_DATE = @IntDate,RATES = @IntRate, INT_CONTACT=@Contact
Where INT_NO = @IntNo
End
End
***************************************
Please assist to get the text boxes filled
Thanks
[Agent_Spock]
- added code brackets
indentation and correct languages