Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i click on the button i want to display the values in gridview which get from the text boxes but it dnt show
how to refresh gridview after get the values from textbox.(I connected the gridview directly to the sql database )
Please help me
Posted
Updated 13-Mar-13 21:12pm
v2
Comments
Anurag Sinha V 14-Mar-13 3:21am    
Hi,

Please post the code and wahtever you have tried.
It will help us in understanding the situation.

-Regards
manjujasmine 14-Mar-13 4:13am    
protected void Button1_Click(object sender, EventArgs e)
{

string sqlCon = ConfigurationManager.ConnectionStrings["cnstr"].ToString();
SqlConnection con = new SqlConnection(sqlCon);
SqlCommand cmd = new SqlCommand();
if(Page.IsPostBack)
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "VIEW_UPDATNGWBSTS";
cmd.Parameters.Add("@portno", SqlDbType.VarChar, 100).Value = TextBox2.Text.Trim();
cmd.Parameters.Add("@webname", SqlDbType.VarChar, 100).Value = TextBox1.Text.Trim();
//cmd.Parameters.Add("@CreatedDate", SqlDbType.Date);

cmd.Parameters.Add("@error", SqlDbType.VarChar, 100);
cmd.Parameters["@error"].Direction = ParameterDirection.Output;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
string msg;
msg = (string)cmd.Parameters["@error"].Value;
Label1.Text = msg.ToString();
}
catch (SqlException ex)
{
throw ex;
}
finally
{
cmd.Dispose();
if (con != null)
{
con.Close();
}}}}
STORED PROCEDURE
CREATE PROCEDURE VIEW_UPDATNGWBSTS
@webname varchar(100),
@portno varchar(100),
@error varchar(100) out
AS
BEGIN

declare @a int
declare @Createdate date
declare @a1 int
set @a=(select count(WebsiteName) from Websitedtls where WebsiteName=@webname)
set @a1=(select count(WebsiteName) from Updatngwbsts where WebsiteName=@webname)

if(@a=0)
begin
insert into Websitedtls (PortId,WebsiteName,Createdate)values(@portno,@webname,GETDATE())
set @error='updated successfully'
select WebsiteName from Websitedtls
if(@a1!=0)
delete from Updatngwbsts where WebsiteName=@webname
end
else
set @error='websitename already exist'

END
GO

Anurag Sinha V 14-Mar-13 5:56am    
Hi,
Edit your question and add the code what you have pasted over here.
Its unreadable here.

-regards

1 solution

after your gridview function...

just load your gridview function again...

EX :
loadgridview();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900