|
hi friends
i have one gridview in which i have one delete button
.i write code for confirmation to delete on row_deleting events of datagrids.
But i am facing from one problem.
When first time i click on button then its doesnt give any confirm message after that when i click again then it gives message.
Plz help me out
my code is
protected void GV_userlist_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
LinkButton bt = (LinkButton)GV_userlist.Rows[e.RowIndex].FindControl("BT_delete");
bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');");
}
thanks
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|
|
Hi,
When the page is first rendered, the link button will not have the
onclick attribute.
U R adding the confirmation property after the page has been posted back.
The newly rendered page will have the link button with onclick attribute set.
That is why, the confirmation messaged is displayed for the second time alone.
U will have to add the onclick attribute before the page is loaded for the first time.
Try this:
GV_userlist.Databind();
for(int i=0;i<GV_userlist.Rows.Count;i++)
{
LinkButton bt = (LinkButton)GV_userlist.Rows[i].FindControl("BT_delete");
bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');");
}
Regards,
Arun Kumar.A
|
|
|
|
|
Call on page load even it will work properly
page load()
{
bt.Attributes.Add("OnClick", "return window.confirm('Are you sure want to remove this user?');");
}
Sujit
|
|
|
|
|
Why not just add it to the tag in the aspx page?
<asp:LinkButton OnClientClick="return window.confirm('Are you sure want to remove this user?');"></asp:LinkButton>
|
|
|
|
|
Hi plz help
This code is not working ,i m using asp.net 2.0 with C#
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if ((txtUser.Text == ds.Tables["CreateAccount"][i]["User_Name"]) && (txtPassword.Text == ds.Tables["CreateAccount"][i]["Password"]))
Response.Write("You have succesfully logged in");
else
Response.Write("User Name Does Not Exist");
}
Thanks
CARE CAREER
|
|
|
|
|
Care Career wrote: This code is not working
That is vague. What do you mean by "not working"?
|
|
|
|
|
I'd probably use something like
if ((ds.Tables["CreateAccount"].Select(string.format("User_Name = '{0}' AND Password = '{1}'", new object []{txtUser.Text,txtPassword.text})).length ==1)
//login message
else
//failed message
except i wouldn't process the message like that, i'd do a query such as:
Select count(*) from users where User_Name = <username> AND Password = <password>
and check that the return value was 1. The danger would be that someone will pick up your asp.net login function and deploy it in winforms where the client would have a list of all the username / password entries in the database.
Russell
|
|
|
|
|
The code will produce output for all row of the table. So user never understand that he successfully logged in or not.
|
|
|
|
|
Well firstly you can't apply indexing with [] to a DataTable - it should be more like this (note bold text)
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if ((txtUser.Text == ds.Tables["CreateAccount"].Rows[i]["User_Name"]) &&
(txtPassword.Text == ds.Tables["CreateAccount"].Rows[i]["Password"]))
{
Response.Write("You have succesfully logged in");
}
else
{
Response.Write("User Name Does Not Exist");
}
}
Also - I'm no C# guru but I find using the curly braces helps improve readability - one of the experts can correct me if I'm wrong but I don't see any harm in using curly braces in your "if" statement in this context.
Secondly, how do you know that the username doesn't exist if the password is wrong? I'd suggest either breaking it down into 2 separate helper functions to determine where the problem is or (easier) changing the response to "Either the username or password is incorrect".
Thirdly, you are passing the password as plaintext, which leads me to assume you're saving the password as plain text - bad idea. Rather use a hash to encrypt the password before processing or saving. Take a look at this[^]
|
|
|
|
|
Have you tried putting a .ToString() at the end of the DataSet?
<br />
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)<br />
{<br />
if ((txtUser.Text == ds.Tables["CreateAccount"].Rows[i]["User_Name"].ToString()) &&<br />
(txtPassword.Text == ds.Tables["CreateAccount"].Rows[i]["Password"].ToString()))<br />
{<br />
Response.Write("You have succesfully logged in");<br />
}<br />
else<br />
{<br />
Response.Write("User Name Does Not Exist");<br />
}<br />
}<br />
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
And to add to that in your for loop, its zero based..you need to make it like this:
<br />
for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)<br />
{<br />
<br />
}<br />
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
I did it "off-the-cuff" & missed that one (oops! & thanks), what did you think of the rest or the advice?
|
|
|
|
|
ismailiiuc is right. This will loop through the whole DataSet.
what you should do is take it out of a loop all together. Its not needed.
There should only be one username and password in there.
after you fill your DataSet just do this:
<br />
if (txtUser.Text == ds.Tables["CreateAccount"][0]["User_Name"].ToString() && txtPassword.Text == ds.Tables["CreateAccount"][0]["Password"].ToString())<br />
{<br />
Response.Write("You have succesfully logged in");<br />
}<br />
else<br />
{<br />
Response.Write("User Name Does Not Exist");<br />
}<br />
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
use this to find data from table
ds.Tables["CreateAccount"].rows[i]["User_Name"].tostring();
or
ds.Tables[0].rows[i]["User_Name"].tostring();
Sujit
|
|
|
|
|
I have a webform that includs the xml web server control which uses the xml file and xsl file to show my CV data(doesn't use ado.net) So how could I get a printable format like PDF from this page?.
I am too late but i will never give up
|
|
|
|
|
Hi
Tell me In asp.net CofigurationSetting class from which Namespace is derived.
& also tell me Wht is the diff. b/w Covert & cast in SQL SERVER.
Thanks & Regards
CARE CAREER
|
|
|
|
|
Care Career wrote: Tell me In asp.net CofigurationSetting class from which Namespace is derived.
It isn't in ASP.NET framework. It is in the main body of the .NET framework in the system.Configuration namespace.
Care Career wrote: tell me Wht is the diff. b/w Covert & cast in SQL SERVER
Now this really ought to be in a different forum. But here's the documentation for CAST and CONVERT[^]
|
|
|
|
|
Hi,
Diff. between CAST and CONVERT
If you're just changing data from one form to another for use, such as changing a "31" from a varchar to an int, use CAST; Convert offers more options than cast which may lead to more processing time. And by this, I of course mean MINIMAL, not noticeable processing time. Convert allows you to add a format style to your convertion, if you want it to. For example, if you're changing a date to a string, you can say which part of the date to return instead of returning the whole thing and making .NET format it.
CONVERT is specific to SQL Server, and allows for a greater breadth of flexibility when converting between date and time values, fractional numbers, and monetary signifiers.
Regards,
Sandeep Kumar.V
|
|
|
|
|
Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.
Syntax
Using CAST:
CAST ( expression AS data_type )
Using CONVERT:
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Regards,
Satips.
|
|
|
|
|
Hi,
I have an .aspx page with an asp:Table and a button. When the button is clicked I want the clik event handler to add a row to the table programatically.
The code in the event handler is like so:
<br />
TableRow row = new TableRow();<br />
<br />
TableCell cell = new TableCell();<br />
cell.BorderColor = Color.Black;<br />
cell.BorderStyle = BorderStyle.Dashed;<br />
cell.BorderWidth = new Unit("1");<br />
<br />
<br />
cell.Text = "test";<br />
<br />
row.Cells.Add(cell);<br />
<br />
<br />
tblEval.Rows.Add(row);<br />
<br />
Unfortuantely I can only see the first row getting added on the page - subsequent button clicks have no effect; although when stepping through in the debugger I can see that the asp:table actually gets the new rows added to it, I just can't see it.
What am I doing wrong? Any help is very much appreciated.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Are you binding the table to datagrid or datalist to display it...if so update the datagrid by binding it again in the buttonclick event.
Koushik
|
|
|
|
|
No, I'm not binding it to anything at all. The table is declared in the .aspx table and the idea is that every button click adds a new row to it which the user can then fill out.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
As the web is stateless env...that's why you dont know how many times the user clicks on this button...So just an idea..store the number of clicks into session variable
<< >>
|
|
|
|
|
Thank you. I tried to do this and now I can get it to works. D
ynamically created tables isn't part of the view state, and apparently that also pertains to the table structure itself.
Anyway, now I can get the table constructed as I wanted, now I just need to save the table contents proper.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
you should do it like this
row = tblEval.newRow()
tblEval.Rows.Add(row)
|
|
|
|