gridview选择不填写表单上的thr控件 [英] gridview selection not filling thr control on form

查看:62
本文介绍了gridview选择不填写表单上的thr控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码必须填写表格上的文本框,但按下选择按钮时只有一个文本框







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)
{
   //txtSave.Enabled = false;
   try
   {
      //connection to the database
      //
      //
      string str;
      str = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
      SqlConnection sqlcon = new SqlConnection(str);

      string intno;

      //Get the intno
      intno = GridView1.SelectedRow.Cells[1].Text;

      //call the stored procedure
      SqlCommand SqlCmd = new SqlCommand("sp_Getloanid", sqlcon);
      SqlCmd.CommandType = System.Data.CommandType.StoredProcedure;

      //Supply the User_id parameter
      SqlCmd.Parameters.AddWithValue("@INTNO", intno);

      //Create and supply the output parameters

      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;

      //Open the sql data connection
      sqlcon.Open();

      //Execute the stored procedures
      SqlCmd.ExecuteNonQuery();

      //Assign the results to the controls
      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
/****** Object:  StoredProcedure [dbo].[sp_Get_Loanid]    Script Date: 05/26/2014 11:34:24 ******/
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





******************** *******************



请协助填写文本框



谢谢



[Agent_Spock]

- 添加代码括号

<小> <小>缩进和正确的语言



***************************************

Please assist to get the text boxes filled

Thanks

[Agent_Spock]
- added code brackets
indentation and correct languages

推荐答案

那是因为你没有分配任何值t o存储过程中的参数。



由于这些是输出参数,因此您应该为它们分配一些内容以获取它们的值。
That is because you are not assigning any values to the parameter inside the Stored Procedure.

As those are Output Parameters, so you should assign something to them in order to get their value.


这篇关于gridview选择不填写表单上的thr控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆