Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

How to save respected row records in gridview using user login to another table based on button filed? If end user try to click on save button if the user is not login I need to redirect login page, if the user is already login I need to save in another table.


Ex: Just like wish list or save items etc...

Thanks in advance.
Posted
Comments
[no name] 16-Sep-14 2:55am    
show your code please

you talk about 2 different task once the user click the button here call a method to check for the user is logged in or not which return a Boolean then check for this return if true go on and save the data otherwise redirect to log in page

additional information copied from redundant solution 2 by same person after comment from OP
if you mean by number 1 the quantity , try to save it to variable and the convert it to string or use the following
SQL
"insert into savetable(userid,productid,Quantity) values(" + Userid.Value.tostring() + "," + str+ "," + 1.tostring() + ") ";
 
Share this answer
 
v2
Comments
Member 10021658 16-Sep-14 2:49am    
Thanks for reply. Forget about login credentials, now how to save the row records using the login
email id?
[no name] 16-Sep-14 3:16am    
explain more please , do u want saving the login email id in database ,
please show your code
Member 10021658 16-Sep-14 3:30am    
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int i = GridView1.SelectedIndex;

string str = GridView1.Rows[i].Cells[1].Text;

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Constring"].ConnectionString);
a.Open();

string strinsert = "insert into savetable(userid,productid,Quantity) values('" + Userid.Value + "','" + str+ "','" + 1 + "') ";

SqlCommand cmd = new SqlCommandstrinsert , con);
cmd.ExecuteNonQuery();
a.Close();
}
Member 10021658 16-Sep-14 3:31am    
But I don't want to use these type of code I need to insert normal insert query only.
[no name] 16-Sep-14 7:38am    
if you mean by number 1 the quantity , try to save it to variable and the convert it to string or use the following

"insert into savetable(userid,productid,Quantity) values(" + Userid.Value.tostring() + "," + str+ "," + 1.tostring() + ") ";
try this


string insert=("insert into savetable(userid,productid,Quantity) values(" + Userid.Value.tostring() + ",'" + str+ "'," + 1.tostring() + ") ");
 
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