.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Question about a code I need to alter

Posted By: bezacom     Posted Date: June 08, 2014    Points:5   Category :ASP.Net
Hey guys,

I'm new here and I have a question.

I have this code and I need to remove the part where it adds the information to the DB.

I tried many things (without knowing html), but none worked.

I think, this line " DB.Instance.InsInfo(info);" is the one who enters the data to the DB but i couldn't make it work without it.

Please HELP!

Thanks!!

Jason.


using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class Main : BasePage
{
public class ShowResult
{
public string Type { get; set;}
public string Value { get; set;}
public string Action { get; set; }

public ShowResult(string type, string value, string action)
{
Type = type;
Value = value;
Action = action;
}
}

protected void Page_Load(object sender, EventArgs e)
{
if (CurrentUser == null)
{
Response.Redirect("Login.aspx");
}
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
List<ShowResult> showResult = new List<ShowResult>();
string allInfo = txtInfo.Text;
var separator = new[] {"\r\n"};
var inputArray = allInfo.Split(separator,StringSplitOptions.None);
foreach (var s in inputArray)
{
Info info = new Info();
info.UserId = CurrentUser.Id;
info.Type = s.Contains("@") ? "Email" : "Domain";
if (info.Type.Equals("Domain"))
{
if (s.Contains("http://www."))
{
info.Value = s.Substring(11, s.Length - 11);
}
else if (s.Contains("http://"))
{
info.Value = s.Substring(7, s.Length - 7);
}
else if (s.Contains("www."))
{
info.Value = s.Substring(4, s.Length - 4);
}
else
{
info.Value = s;

}

}
else
{
info.Value = s;
}

var new_s = info.Value.Split('/');
info.Value = new_s[0];
var res = DB.Instance.InsInfo(info);
if (res =="1")
{
showResult.Add(new ShowResult(info.Type,info.Value,"Approved"));
}
else if (res == CurrentUser.Username)
{
showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + CurrentUser.Username));
}
else
{
showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + res));
}

}

grdResults.DataSource = showResult;
grdResults.DataBind();
}

protected void grdResults_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label action = (Label)e.Row.FindControl("lblAction");

if (action.Text.Contains("Approved"))
{
action.Style["background-color"] = "green";
//action.Style["color"] = "white";
}
else if (action.Text.Contains(CurrentUser.Username))
{
action.Style["background-color"] = "yellow";
//action.Style["color"] = "white";
}
else
{
action.Style["background-color"] = "red";
}



}

}
}

Responses
Author: ASPEvil             
Posted Date: June 12, 2014     Points: 20   


if (res =="1")
{
showResult.Add(new ShowResult(info.Type,info.Value,"Approved"));
}
else if (res == CurrentUser.Username)
{
showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + CurrentUser.Username));
}
else
{
showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + res));
}



Convert the above code to the exactly the below one:-
-----------------------------------------------------
//if (res == "1")
//{
// showResult.Add(new ShowResult(info.Type, info.Value, "Approved"));
//}
//else if (res == CurrentUser.Username)
//{
// showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + CurrentUser.Username));
//}
//else
//{
// showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + res));
//}

---------------------------------------------------

Save your application and run it and check if you got thing, you are looking for.


Thanks.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend