|
Debug the code. Put a breakpoint in your Page_Load and see what is happening. You may have your code inside of a check for IsPostBack and so it only runs the one time.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi,
I was able to solve my issue.
string value = DataBinder.Eval(e.Row.DataItem, "SAPLeader").ToString();
dd.SelectedValue = value;
dd.SelectedIndex = dd.Items.IndexOf(dd.Items.FindByText(value.ToString()));
This is the fixed.
modified 29-Jul-15 13:55pm.
|
|
|
|
|
dd.Text? Shouldn't you use dd.SelectedValue or dd.SelectedItem?
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
I changed it to dd.SelectedValue = value;
It still doesn't work. The issue is that once I select EDIT the current value in the SAPLeader field goes away and the dropdownlist is now showing the first value and that is the one it choses when you select UPDATE. What I would like it do is to select the right dropdown value when the dropdownlist loads.
|
|
|
|
|
try something LIKE:
ddlData.SelectedIndex=ddlData.Items.IndexOf(ddlData.Items.FindByText("value"));
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Automatically send emails at specific date time using asp.net
|
|
|
|
|
You will need to create a Windows service to send out your scheduled emails or task the windows service to call a page from you website that will trigger the sending.
|
|
|
|
|
|
Scott Hanselman has several suggestions for you:
How to run Background Tasks in ASP.NET[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Nice link. Helps me even out!
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
I have Using DevExpress Version 12 I have problem on ASPxGridview on Row selection in Keyboard Up-Down KeyBoard.I Have Set Property "KeyBoardSupport" is "True" It Display On Page load ASPxGridView First row Selected with BackColor is Black.I want first Row Is Select On Mouse Click Then Keyboard Up-Down Arrow Key Row Selction Changed.How?
|
|
|
|
|
|
I am investigating a CSRF finding in asp.net c# code behind as shown in the following code:
LinkButton LinkButtonControl = new LinkButton();
LinkButtonControl.ID = Name;
<pre>
Now, I feel that the following code using ViewStateUserKey is the right approach:
<pre>
protected override OnInit(EventArgs e) {
base.OnInit(e);
if (User.Identity.IsAuthenticated)
ViewStateUserKey = Session.SessionID; }
<pre>
However; another person I work with thinks that the Httputility.htmlencode method is the best way to correct the problem. First I don't know if the Httputility.htmlencode method is the best way and if so I would I use it?
|
|
|
|
|
|
The HtmlEncode method is one of a group of methods used to prevent XSS (Cross-Site Scripting)[^] - that's where you take input from the user and write it to the output without properly encoding it. The method provides zero protection from a CSRF vulnerability.
CSRF (aka XSRF) is a Cross-Site Request Forgery[^] vulnerability. That's where a script on another site can force the user's browser to make an authenticated request to your site without the user's knowledge. It looks like Anil has already given you some good links for dealing with this class of vulnerability.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I want to make one schedule in global.asax page that update date in database if current date is greater then database date. this schedule is run after every 24 hours. I have performed one task for it.
private static void Task()
{
String CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
con.Open();
DateTime Newdate;
DateTime dt;
SqlCommand cmd1 = new SqlCommand("select Date from tblInsertDate", con);
cmd1.ExecuteNonQuery();
List<String> dates = new List<String>();
using (SqlDataReader rdr = cmd1.ExecuteReader())
{
while (rdr.Read())
{
dt = DateTime.ParseExact(rdr["Date"].ToString(), "dd/MM/yyyy", null);
String cd = DateTime.Now.ToString("dd/MM/yyyy");
DateTime CD = DateTime.ParseExact(cd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
int result = DateTime.Compare(dt, CD);
if (result < 0)
{
Newdate = dt.AddDays(7);
DateTime Newdateonly = Newdate.Date;
String Ndate = Newdateonly.ToString("dd/MM/yyyy");
dates.Add(Ndate);
break;
}
}
}
foreach (String dataList in dates)
{
SqlCommand cmd2 = new SqlCommand("update tblInsertDate set Date=@Newdate where Date=@whereDate", con);
cmd2.Parameters.AddWithValue("@Newdate", dataList);
cmd2.Parameters.AddWithValue("@whereDate",dt);
cmd2.ExecuteNonQuery();
}
}
}
all the value of database table is changed. I just want to update date row by row if current date is grater then databse date.
So I have to put one where condition in foreach loop but how to put where condition?
if i try to write
SqlCommand cmd2 = new SqlCommand("update tblInsertDate set Date=@Newdate where Date=@whereDate", con);
cmd2.Parameters.AddWithValue("@Newdate", dataList);
cmd2.Parameters.AddWithValue("@whereDate",dt);
then "dt" is not use as local variable.
|
|
|
|
|
Why are you converting all of your dates to strings, and then parsing them back to dates? Just use them as dates:
dt = DateTime.ParseExact(rdr["Date"].ToString(), "dd/MM/yyyy", null);
dt = rdr.Field<DateTime>("Date");
String cd = DateTime.Now.ToString("dd/MM/yyyy");
DateTime CD = DateTime.ParseExact(cd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
DateTime CD = DateTime.Today;
List<String> dates = new List<String>();
...
Newdate = dt.AddDays(7);
DateTime Newdateonly = Newdate.Date;
String Ndate = Newdateonly.ToString("dd/MM/yyyy");
dates.Add(Ndate);
List<DateTime> dates = new List<DateTime>();
...
dates.Add(dt.AddDays(7).Date);
Having said that, you can replace all of your code with a single query:
private static void Task()
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
using (SqlCommand cmd = new SqlCommand("UPDATE tblInsertDate SET [Date] = DateAdd(day, 7, [Date]) WHERE [Date] < @Today", con))
{
cmd.Parameters.AddWithValue("@Today", DateTime.Today);
con.Open();
cmd.ExecuteNonQuery();
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I created a website but it was built with the wrong code from TFS. Because of this I copy the correct code web folder from my c: drive to the IIS website folder. The website runs fine; however, when I try to build the site in VS I get the following error:
Error 102 The configSource file 'appSettings.config' is also used in a parent, this is not allowed.
|
|
|
|
|
When I try to add the new code to source control I get the following error:
The following IIS Virtual Directories cannot be added to source control at this time because their files do not reside under the Local Path of the root Web site localhost : https://localhost (D:\TAMIS-Root\Web)
Click Continue to add all other Web items to source control. Click Cancel to stop adding files to source control.
|
|
|
|
|
I did have to delete the website from IIS and recreate it.
|
|
|
|
|
sir i made a registration page i want to know how to varification code went to user's email id if we are working on local host without using any gateway and all. i want the code pls help
|
|
|
|
|
|
I want to upload only the details of students belonging to my department, the file is in excel format which contains many columns of which one column is the department column. Now, i have to obtain the column values for each student and compare with that of my department and only, if it matches, it has to upload.
|
|
|
|
|
Very interesting; and what is your question?
|
|
|
|
|
Hi Friends ,
iam using one iframe in my application. In that iframe iam Display another web application in that have registration form with captcha , when our submit the Registration its working in chrome and mozilla but its Not Working in IE because of third party cookies are Disable by Default. how can i enable third party cookies using code.
|
|
|
|