|
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
if (btnSave.Text == "Save")
{
BOStudentDetails ObjStudent = new BOStudentDetails();
ObjStudent.SchoolID = Convert.ToInt32(drpSchool.SelectedValue);
ObjStudent.ClassID = Convert.ToInt32(drpClass.SelectedValue);
ObjStudent.StudentName = txtStudentFname.Text+ ' ' + txtStudentMname.Text + ' ' + txtStudentLname.Text;
//ObjStudent.StudentPhoto = "fsdfs";
ObjStudent.StudentDob = txtdob.Text;
ObjStudent.StudentAddmissionDate = txtAdmissionDate.Text;
ObjStudent.StudentFthName = txtFthName.Text;
ObjStudent.StudentMthName = txtMthName.Text;
ObjStudent.StudentCategory = Convert.ToString(drpCategory.SelectedItem);
ObjStudent.StudentGender = Convert.ToString(drpGender.SelectedItem);
ObjStudent.StudentMobile1 = txtMobile1.Text;
ObjStudent.StudentMobile2 = txtMobile2.Text;
ObjStudent.StudentLandline = txtLandlinePhon.Text;
ObjStudent.StudentDiscription = txtDiscription.Text;
ObjStudent.StudentPrmAdd = txtPrmAdd.Text;
ObjStudent.StudentPrmState =Convert.ToString(drpPrmState.SelectedItem);
ObjStudent.StudentPrmCity = Convert.ToString(drpPrmCity.SelectedItem);
ObjStudent.StudentPrmLocation = Convert.ToString(drpPrmLocation.SelectedItem);
ObjStudent.StudentPrmPin = txtPrmPin.Text;
ObjStudent.StudentCrntAdd = txtCrntAdd.Text;
ObjStudent.StudentCrntState = Convert.ToString(drpCrntState.SelectedItem);
ObjStudent.StudentCrntCity = Convert.ToString(drpCrntCity.SelectedItem);
ObjStudent.StudentCrntLocation = Convert.ToString(drpCrntLocation.SelectedItem);
ObjStudent.StudentCrntPin = txtCrntPin.Text;
if (flupldStdPhoto.HasFile)
{
string StudentExtension = Path.GetExtension(flupldStdPhoto.FileName);
if (!StudentExtension.ToLower().Equals(".gif")
&& !StudentExtension.ToLower().Equals(".jpg")
&& !StudentExtension.ToLower().Equals(".jpeg"))
{
Functions.MsgBox("Director's sign is not in correct format." +
System.Environment.NewLine +
"Signature sign should be gif or jpg or jpeg image.");
return;
}
flupldStdPhoto.SaveAs(Server.MapPath("~/Admin/Student Photo/") + flupldStdPhoto.FileName);
ObjStudent.StudentPhoto = flupldStdPhoto.FileName;
}
balStudentObj.InsertStudent(ObjStudent);
Clear();
ShowAlert(this.Page, "Record inserted successfully");
}
else if(btnSave.Text=="Update")
{
}
}
catch
{
}
}
DAL
----------------
public void InsertSchools(BOStudentDetails ObjStudent)
{
SqlParameter[] paramList =
{
new SqlParameter("@SchoolId",ObjStudent.SchoolID),
new SqlParameter("@ClassId",ObjStudent.ClassID),
new SqlParameter("@StName",ObjStudent.StudentName),
new SqlParameter("@StDob", ObjStudent.StudentDob),
new SqlParameter("@StAdmDate", ObjStudent.StudentAddmissionDate),
new SqlParameter("@StFthName", ObjStudent.StudentFthName),
new SqlParameter("@StMthName", ObjStudent.StudentMthName),
new SqlParameter("@StCat", ObjStudent.StudentCategory),
new SqlParameter("@StGender", ObjStudent.StudentGender),
new SqlParameter("@StMob1", ObjStudent.StudentMobile1),
new SqlParameter("@StMob2", ObjStudent.StudentMobile2),
new SqlParameter("@StLandline", ObjStudent.StudentLandline),
new SqlParameter("@StDiscription", ObjStudent.StudentDiscription),
new SqlParameter("@StprmAdd", ObjStudent.StudentPrmAdd),
new SqlParameter("@StprmState", ObjStudent.StudentPrmState),
new SqlParameter("@StprmCity", ObjStudent.StudentPrmCity),
new SqlParameter("@StprmLoc", ObjStudent.StudentPrmLocation),
new SqlParameter("@StprmPin", ObjStudent.StudentPrmPin),
new SqlParameter("@StcrntAdd", ObjStudent.StudentCrntAdd),
new SqlParameter("@StcrntState", ObjStudent.StudentCrntState),
new SqlParameter("@StcrntCity", ObjStudent.StudentCrntCity),
new SqlParameter("@StcrntLoc", ObjStudent.StudentCrntLocation),
new SqlParameter("@StcrntPin", ObjStudent.StudentCrntPin)
};
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "StudentDetail_Insert_Sp", paramList);
}
|
|
|
|
|
Share the Databind code for drpCrntState .
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
public void BindCStateDrp()
{
var stateList = balStateObj.GetState(0);
drpCrntState.DataSource = stateList;
drpCrntState.DataTextField = "StateName";
drpCrntState.DataValueField = "StateID";
drpCrntState.DataBind();
drpCrntState.Items.Insert(0, new ListItem("--Select State--", "-1"));
}
DAL
-----------------
public List<BOState> GetStates(int stateID)
{
List<BOState> lstState = new List<BOState>();
try
{
SqlParameter[] paramList =
{
new SqlParameter("@State_Id" , stateID)
};
SqlDataReader reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "State_Select_Sp", paramList);
while (reader.Read())
{
BOState state = new BOState();
state.StateID = (Int32)reader[0];
state.StateName = (String)reader[1];
state.StateStatus = (bool)reader[2];
lstState.Add(state);
}
}
catch
{
}
return lstState;
}
|
|
|
|
|
Based on your question & this discussion[^], you have used SelectedValue property instead of DataValueField .
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
This error occurred when your dropdown is already filled and if you try to assign (selects) that value which was selected previously. so can you provide your code?
|
|
|
|
|
thank you ajay sir i have solve my porblem...with your suport...
tripat bala singh
|
|
|
|
|
welcome dear!!!
keep it up... 
|
|
|
|
|
Hi Friend,
put you code inside on IsPostBack ==false like below code and put the DataTextField and DataValueField properly like this. this code should be in Page_Load events.
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("your connection string here");
SqlDataAdapter da = new SqlDataAdapter("Select StateId,StateName From StateMaster", con);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "StateName"; // your dispaly field in dropdownlist
DropDownList1.DataValueField = "StateId"; // your value field which you will stare in database
DropDownList1.DataBind();
con.Close();
}
Anil Pathak
worked on technologies like C#, VB.net, ASP.net, Web Service, WCF, WPF, Silver Light, MVC 3.0, Jquery, Sql Server.
|
|
|
|
|
thank you anil sir i have solve my porblem...with your suport...
tripat bala singh
|
|
|
|
|
I just saw IE11 preview is available.
I am so seriously sick of this , every-time Microsoft pushes out a new browser we get a crap load of support call over websites not working or displaying incorrectly.
Yes Firefox has a much more frequent release schedule but at least they keep things the same.
Every single IE version is like a whole new compulsory browser we have to babysit , because we have to consider everyone who hasn't upgraded to the latest version
The Last time Microsoft released a browser version the entire Authentication based system for their own framework went to hell , and we had a whole bunch of very p-d of customers phoning us. Never mind the huge amount of dev resources we had to pull off projects to fix existing projects.
My question is when Microsoft make screw ups like this , at what point can we start sending our development bill to them ?!
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
This is not the place for this sort of rant. Either use the Lounge[^], or one of Microsoft's own websites.
Veni, vidi, abiit domum
|
|
|
|
|
how to split an excel workbook into two when it exceeds 600 kb in c#.net
|
|
|
|
|
|
hello frnds , iam new to the CMS. show me the sample example
Mr.VJ
|
|
|
|
|
Not a specific question but this[^] could have help you.
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
1 - i make text box with auto complicate extended
2- i pot my connection string
"
<connectionStrings>
<add name="conn" connectionString="Data Source=.;Initial Catalog=Tranning;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="tempdbConn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\tempdb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
"
and i make method
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> SearchCustomers(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["conn"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select No_Trainee from Annual_Plan where No_Trainee like @SearchText + '%' ";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> customers = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(sdr["No_Trainee"].ToString());
}
}
conn.Close();
return customers;
}
}
}
and still my text Box not get values from database
Please need help !!!
|
|
|
|
|
1. Is your SearchCustomers method called at all?
2. What auto-complete do you use? JQuery one?
3. How is your text box set up to use it?
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
Hi, the asp.net identity use entity framework native
Any suggestion for override controls?
Example?
Pls
|
|
|
|
|
I'm having a problem reading data from a view built in a sql server db. I'm trying to use the same code to read from the view as I have used to read from sql server tables in the past through vb.net/asp, but it is not working. Vbcode bombs on the "sqlRead = sqlCmd.ExecuteReader()" line.
ASP
[code]
<pre lang="xml"><%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Lifepoint Dashboard</title>
<style type="text/css">
#form1
{
height: 452px;
width: 856px;
}
#frmLPNT
{
height: 565px;
}
</style>
</head>
<body>
<form id="frmLPNT" runat="server">
<div>
</div>
<asp:Image ID="Image1" runat="server" Height="90px"
ImageUrl="~/images/IT&SLogo.jpg" Width="90px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
<br />
<asp:SqlDataSource ID="dsLPNT" runat="server"
SelectCommand="SELECT [Incident_Number], [COID],[Vendor_Ticket_Number] , [Status], [Status_Reason],
[Priority], [Owner_Group], [Owner], [Assigned_Group], [Assignee],
[Product_Name], [First_Name], [Last_Name]
FROM [hca_incident_view]
WHERE (([Status] = 'In Progress') AND ([Company] = 'LifePoint') AND ([COID] = @COID))"
ConnectionString="<%$ ConnectionStrings:RemedyConnection %>"
DeleteCommand=""
InsertCommand=""
UpdateCommand="">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCOID" Name="COID" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:DropDownList ID="ddlCOID" runat="server" onSelectedIndexChanged="ddlCOID_SelectedIndexChanged" AutoPostBack="true" Height="22px" Width="331px">
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<div style="margin-left: 280px">
<br />
</div>
</form>
</body>
</html></pre>
[/code]
VB.net
[code]
<pre lang="vb">Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Data.DataRowView
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub frmLPNT_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles frmLPNT.Load
Me.ddlCOID.Items.Add("Select LifePoint Facility...")
Me.ddlCOID.Items.Add("Acadian Regional Medical Center")
Me.ddlCOID.Items.Add("Ashley Valley Medical Center")
Me.ddlCOID.Items.Add("Ashley Valley Medical Center")
Me.ddlCOID.Items.Add("Bolivar Medical Center")
Me.ddlCOID.Items.Add("Colorado Plains Medical Center")
Me.ddlCOID.Items.Add("Ennis Regional Medical Center")
Me.ddlCOID.Items.Add("Valley View Medical Center")
Me.ddlCOID.Items.Add("Lake Havasu Regional Medical Center")
Me.ddlCOID.Items.Add("Memorial Medical Center Resources")
Me.ddlCOID.Items.Add("Los Alamos Medical Center")
Me.ddlCOID.Items.Add("Memorial Hospital of Martinsville")
Me.ddlCOID.Items.Add("Minden Medical Center")
Me.ddlCOID.Items.Add("Northeastern Nevada Regional")
Me.ddlCOID.Items.Add("Palestine Regional Medical Center")
Me.ddlCOID.Items.Add("Parkview Regional Hospital")
Me.ddlCOID.Items.Add("LPNT CORP")
End Sub
Public Sub ddlCOID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCOID.SelectedIndexChanged
Dim strCOID As String = TryCast(sender, DropDownList).SelectedValue
Select Case strCOID
Case "Acadian Regional Medical Center"
strCOID = "02751"
Case "Andalusia Regiona Hospital"
strCOID = "05356"
Case "Ashley Valley Medical Center"
strCOID = "05424"
Case "Bolivar Medical Center"
strCOID = "02723"
Case "Colorado Plains Medical Center"
strCOID = "02740"
Case "Ennis Regional Medical Center"
strCOID = "02750"
Case "Valley View Medical Center"
strCOID = "02757"
Case "Lake Havasu Regional Medical Center"
strCOID = "02758"
Case "Memorial Medical Center Resources"
strCOID = "02765"
Case "Los Alamos Medical Center"
strCOID = "02779"
Case "Memorial Hospital of Martinsville"
strCOID = "02781"
Case "Minden Medical Center"
strCOID = "02782"
Case "Northeastern Nevada Regional"
strCOID = "02784"
Case "Palestine Regional Medical Center"
strCOID = "02785"
Case "Parkview Regional Hospital"
strCOID = "02790"
Case "LPNT CORP"
strCOID = "05433"
End Select
'MsgBox(strCOID)
Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("RemedyConnection").ConnectionString)
Dim sSql As System.Xml.Linq.XElement = <sql> SELECT [Incident_Number], [COID],[Vendor_Ticket_Number] , [Status], [Status_Reason],[Priority], [Owner_Group], [Owner], [Assigned_Group], [Assignee], [Product_Name], [First_Name], [Last_Name] FROM ([hca_incident_view]) WHERE ([Status] = 'In Progress') AND ([Company] = 'LifePoint') AND ([COID] = '<%= strCOID %>')
</sql>
'This code executes your sql command
Dim sqlCmd As New SqlCommand(sSql.Value, sqlConn)
Dim sqlRead As SqlDataReader
If sqlConn.State <> ConnectionState.Open Then
sqlConn.Open()
End If
sqlRead = sqlCmd.ExecuteReader()
sqlRead.Read()
sqlRead.Close()
'MsgBox("Connected")
'Close the connection
sqlConn.Close()
For i As Int16 = 0 To Me.ddlCOID.Items.Count - 2
For j As Int16 = Me.ddlCOID.Items.Count - 1 To i + 1 Step -1
If Me.ddlCOID.Items(i).ToString = Me.ddlCOID.Items(j).ToString Then
Me.ddlCOID.Items.RemoveAt(j)
End If
Next
Next
End Sub
End Class</pre>
[/code]
|
|
|
|
|
Firstly, your post is extremely hard to read, since you haven't formatted your code. Please edit your post and use the code button on the editor toolbar to format your code blocks.
Secondly, you're building a dynamic query, which could leave your code open to SQL Injection[^]. In this case, since you're using hard-coded strings, nothing bad will happen. However, if you forget and later modify the query to include input which is under the user's control, this will become a serious problem. Get into the habit of using parameterized queries even when you're sure that they can't be exploited.
You're executing the query, but you're never actually using the data it returns. You simply call .Read and then close the connection. You need to read the data from the SqlDataReader and do something with it.
You should wrap the SqlConnection , SqlCommand and SqlDataReader variables in a Using block[^], to ensure that they are cleaned up even if the code throws an exception.
Finally, you need to post the details of the exception that's thrown. Saying "the code bombs" isn't enough for anyone to diagnose the problem!
Dim sSql As String = "SELECT [Incident_Number], [COID], [Vendor_Ticket_Number], [Status], [Status_Reason], [Priority], [Owner_Group], [Owner], [Assigned_Group], [Assignee], [Product_Name], [First_Name], [Last_Name] FROM [hca_incident_view] WHERE [Status] = 'In Progress' AND [Company] = 'LifePoint' AND [COID] = @COID"
Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("RemedyConnection").ConnectionString)
Using sqlCmd As New SqlCommand(sSql, sqlConn)
sqlCmd.Parameters.AddWithValue("@COID", strCOID)
sqlConn.Open()
Using sqlRead As SqlDataReader = sqlCmd.ExecuteReader()
While sqlRead.Read()
' TODO: Do something with the data here...
End While
End Using
End Using
End Using
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That worked perfectly. Not sure why my other method didnt work because it worked with another database I use. Anyways...many thanks!
|
|
|
|
|
Hi Friends... I am developing Video Websites..
I wants to secure the flv files from downloading and encryting source code parameter value (value="flv=videos/conversation/intro.flv) from viewing by right click..
My code below
<object type="application/x-shockwave-flash" data="videos/player_flv_mini.swf" width="426" height="240">
<param name="movie" value="videos/player_flv_mini.swf" />
<param name="allowFullScreen" value="true" />
<param name="sharedSecret" />
<param name="FlashVars" enableviewstate="false" value="flv=videos/conversation/intro.flv&autoplay=1&width=426&height=240&playercolor=5f9906&loadingcolor=ff5c29&buttoncolor=fcfcfa&slidercolor=fcfcfa" />
</object>
I want to hide
value="flv=videos/conversation/intro.flv this to this like value="jhgdb chud jgcdb vcagsb avbhvbsdhv"
Please anyone can help me out..
send the code behind....
|
|
|
|
|
Hi Friends,
I have gridview with 2 columns "Tower" - dropdown template field and "Country" - dropdown template field.
I have datatable with 2 columns Tower and Country and has 100 rows.
Now my need is to attach this datatable to gridview, but i should not get 100 rows in gridview, i should get only one row, where Tower and Country dropdown should contain all 100 rows data as Listitem respectively.
(i.e.,) Gridview should contain only one row with 100 items in each column dropdown.
Please help in this, I am stuck in this.
Regards,
Priyaa.
|
|
|
|
|
i have used a stored procedure which requires joining with 10 tables (can't reduce this). It takes 8 seconds to load the page with this procedure. Also i have 2 more procedures with simple select queries for validation.
Can i increase the performance by using linq or anyother methods instead of using this procedures. please help me out .
|
|
|
|
|
|