TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Debasis Mohapatra
NA
381
56.5k
EDIT REcords from gridview code
Dec 21 2018 6:35 AM
Please check the below code which i have marked as comment
This is my store procdure code in here all is ok but check my the asp.net code
USE [DBBJBPL1]
GO
/****** Object: StoredProcedure [dbo].[fabric_ins] Script
Date
: 21/12/2018 12:38:34 ******/
SET
ANSI_NULLS
ON
GO
SET
QUOTED_IDENTIFIER
ON
GO
ALTER
procedure
[dbo].[fabric_ins]
(
-- @quality varchar(50)=null
--,@colors varchar(50)=null
--,@width decimal(18,2)=0.0
--,@length decimal(18,2) =0.0
--,@operationType int=0
--,@itemcode varchar(10)=null
--,@ret varchar(250) OUTPUT
@fabrictype
varchar
(50)=
null
,@weave
varchar
(50)=
null
,@colour
varchar
(50)=
null
,@lamination
bit
=0
,@gsm
int
=0
,@width
decimal
(18,2)=0.0
,@operationType
int
=0
,@itemcode
varchar
(10)=
null
,@ret
varchar
(250)
OUTPUT
)
AS
BEGIN
if @operationType=0
begin
BEGIN
TRY
SET
NOCOUNT
ON
SET
XACT_ABORT
ON
BEGIN
TRANSACTION
insert
into
ItemMaster(itemcd,itemdescription,width,isLaminated,GSM,colour,mtype )
values
(
[dbo].[AUTO_DOC_CODE](
'IC'
),@fabrictype,@width,@lamination,@gsm,@colour,
'FABRIC'
)
set
@ret=
'S'
UPDATE
documentnumber
SET
doc_last_srl_no=
SUBSTRING
([dbo].[AUTO_DOC_CODE](
'IC'
),4,5),
doc_suff=dbo.fnGetFiscalYear(),
doc_no_last_update=GETDATE()
WHERE
doctype=
'IC'
and
location=
'01'
COMMIT
TRANSACTION
END
TRY
BEGIN
CATCH
IF @@TRANCOUNT > 0
AND
XACT_STATE() <> 0
ROLLBACK
TRAN
SET
@RET=ERROR_MESSAGE();
END
CATCH
end
else
if @operationType=1
begin
select
*
from
itemmaster
where
itemcd=@itemcode
end
else
if @operationType=2
begin
update
itemmaster
set
GSM=@gsm,colour=@colour,width=@width
where
itemcd=@itemcode
end
--else if @operationType=3
--begin
-- Delete ItemMaster where itemcd=@itemcode
--end
END
asp.net code
protected
void
lnkdit_Click(
object
sender, EventArgs e)
{
LinkButton lnkdit = (LinkButton)sender;
GridViewRow Grow = (GridViewRow)lnkdit.NamingContainer;
Label lblitemcds = (Label)Grow.FindControl(
"lblitemcds"
);
editrecords(lblitemcds.Text);
pnladd.Visible =
true
;
pnlview.Visible =
false
;
}
private
void
editrecords(
string
lblitemcds)
{
DataTable dt =
new
DataTable();
try
{
if
(connection.State == ConnectionState.Open)
connection.Close();
connection.Open();
SqlDataAdapter sda =
new
SqlDataAdapter(
"fabric_ins"
, connection);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
//sda.SelectCommand.Parameters.AddWithValue("@fabrictype", "");
//sda.SelectCommand.Parameters.AddWithValue("@weave", "");
//sda.SelectCommand.Parameters.AddWithValue("@colour", "");
//sda.SelectCommand.Parameters.AddWithValue("@lamination", "");
//sda.SelectCommand.Parameters.AddWithValue("@gsm", "");
//sda.SelectCommand.Parameters.AddWithValue("@width", 0.0);
sda.SelectCommand.Parameters.AddWithValue(
"@operationType"
, 1);
sda.SelectCommand.Parameters.AddWithValue(
"@itemcode"
, lblitemcds);
sda.SelectCommand.Parameters.Add(
"@ret"
, SqlDbType.VarChar, 250);
sda.SelectCommand.Parameters[
"@ret"
].Direction = ParameterDirection.Output;
sda.Fill(dt);
if
(dt.Rows.Count > 0)
{
txtgsm.Text = dt.Rows[0][
"gsm"
].ToString();
ddlcolour.SelectedValue = dt.Rows[0][
"colour"
].ToString();
txtwidth.Text = dt.Rows[0][
"width"
].ToString();
}
}
catch
(Exception ex)
{
//throw;
}
finally
{
if
(connection.State == ConnectionState.Open)
connection.Close();
}
}
Reply
Answers (
1
)
interview questions of product based comapny
How to use Multiple MySQL Connector