|
Try concatenating the two columns in your select statement.
Example:
select empid empname + ' ' + empdept + ' ' + empbranch
|
|
|
|
|
Hi David,
i don't want to merge values,need to show them in separate table under same heading
|
|
|
|
|
SELECT ISNULL(empid, '') + ' ' + ISNULL(empname, '') AS emp_personal, ISNULL(empdept, '') + ' ' + ISNULL(empbranch, '') AS emp_official
FROM emp
check this query and please confirm me is this working for you or not?
|
|
|
|
|
I am using a CascadingDropdown for three dropdownlists for country,state and district.when the country is selected state will automatically get values,i have a tab index issue if the state value doesnt come on tabpress the control will on the fourth control that is after district dropdown.I had made tab index correctly any way to make it work nicely.If state comes up with value then no problem.if it doesn't then irritating
lk
modified 16-Apr-14 0:58am.
|
|
|
|
|
Hi all. I am writing a program using Microsoft Visual Web Developer. I have 3 textboxes (TextBox1, TextBox2 and TextBox3) and a button. I want to use a foreach loop to clear textboxes.
For some reason this code doesnt work on a Webform. While debugging it, the debugger skips the line: "if (c is TextBox)" and so the textboxes dont get cleared. Here control = {ASP.default_aspx}
When I use the below code in Microsoft Visual C# with a windows form it works. What could be wrong?
Here is the code:
protected void Button1_Click(object sender, EventArgs e)
{
ClearTextBoxes(this);
}
public void ClearTextBoxes(Control control)
{
foreach (Control c in control.Controls)
{
if (c is TextBox)
{
((TextBox)c).Text = " ";
}
}
|
|
|
|
|
Are your TextBoxes immediate descendants of the page? It's unlikely; you've probably got several layers of controls between them.
Try this:
public void ClearTextBoxes(Control control)
{
foreach (Control c in control.Controls)
{
var textBox = c as TextBox;
if (textBox != null)
{
textBox.Text = " ";
}
else if (c.HasControls)
{
ClearTextBoxes(c);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
try this code
protected void Button1_Click(object sender, EventArgs e)
{
ClearTextBoxes(Page.Controls);
}
void ClearTextBoxes(ControlCollection control)
{
foreach (Control ctrl in control)
{
if (ctrl is TextBox)
((TextBox)ctrl).Text = string.Empty;
ClearInputs(ctrl.Controls);
}
}
|
|
|
|
|
|
|
#region Clear all text boxes page value (for server-side controls)
///
/// ex:FindTextBox(this);
///
/// <param name="c" />
public void FindTextBox(Control c)
{
if (c.Controls != null)
{
foreach (Control x in c.Controls)
{
if (x is System.Web.UI.WebControls.TextBox)
{
((System.Web.UI.WebControls.TextBox)x).Text = string.Empty;
}
FindTextBox(x);
}
}
}
#endregion
#region Clear all text boxes page value (for client side controls)
///
/// ex:FindHtmlInputText(this);
///
/// <param name="c" />
public void FindHtmlInputText(Control c)
{
if (c.Controls != null)
{
foreach (Control x in c.Controls)
{
if (x is System.Web.UI.HtmlControls.HtmlInputText)
{
((System.Web.UI.HtmlControls.HtmlInputText) x).Value = string.Empty;
}
if (x is System.Web.UI.HtmlControls.HtmlTextArea)
{
((System.Web.UI.HtmlControls.HtmlTextArea)x).Value = string.Empty;
}
FindHtmlInputText(x);
}
}
}
#endregion
ex:FindHtmlInputText(this);
Hope you can help!!!
|
|
|
|
|
I Want To Validate my Windows Project while User can not Share this project to another or in One year Project will be Expired
Like An Antivirus Program Expired after One or two months
|
|
|
|
|
I would suggest you to google like this: "implementing licensing for trial versions in windows applications"
Be a good professional who shares programming secrets with others.
|
|
|
|
|
First off, this is the ASP.Net forum and not the Windows Application forum. Secondly, you need to implement a license. There are many, many ways to do it. Some are easier but not as resistant to hacking and others are more complex to implement. You may want to research online the various options and then decide what works best for you.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Sorry But can u Suggests me some Ways to do that
|
|
|
|
|
.NET Reactor[^] is a powerful .NET Code Protection & Software Licensing System. Protect, encrypt, obfuscate, merge and license your .NET assemblies.
Maulik Dusara
Sr. Sofware Engineer
|
|
|
|
|
I Have Downloaded . net Reactor.. but it working.. i think it is very difficult to use.. can you suggest me how can i use .Reactor to make a License Project.
|
|
|
|
|
hi,
can anyone suggest me the best book for mvc4 pls
|
|
|
|
|
http://it-ebooks.info/book/1617/
try this link to download the book on mvc4
|
|
|
|
|
|
|
Ok this has sort of been asked before but also somewhat differently here. I have a regular drop down (not connected to a database) that just has the topics of subjects.
This is a sample of what I have:
<asp:DropDownList id="ddlcourseType" runat="server"
onselectedindexchanged="ddlcourseType_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem Value="None">Please Select</asp:ListItem>
<asp:ListItem Value="Engl">English</asp:ListItem>
<asp:ListItem Value="Math">Math</asp:ListItem>
<asp:ListItem Value="Soci">Social Studies</asp:ListItem>
<asp:ListItem Value="Scie">Science</asp:ListItem>
<asp:ListItem Value="Hist">History</asp:ListItem>
</asp:DropDownList>
I want to make it so that when it changes the next part will search and select teachers that teach that specific subject. I am using an Access Database for connection.
I have pieced together some of what others did in an attempt to get it to work but no.
protected void ddlcourseType_SelectedIndexChanged(object sender, EventArgs e)
{
OleDbConnection dbConn = null;
OleDbCommand dbCmd;
OleDbDataReader dr;
String strConnection;
String strSQL;
string path = Server.MapPath("eAcademy_DB.mdb");
string Teachable = Convert.ToString(ddlcourseType.SelectedValue);
strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
dbConn = new OleDbConnection(strConnection);
dbConn.Open();
strSQL = "select * from tblEmployee where canTeach=" + Teachable;
dbCmd = new OleDbCommand(strSQL, dbConn);
DataSet ds = new DataSet();
dbConn.Close();
ddlTeacher.DataSource = ds;
ddlTeacher.DataTextField = "emp_ID";
ddlTeacher.DataValueField = "emp_ID";
ddlTeacher.DataBind();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
if (ddlTeacher.SelectedValue == "0")
{
ddlTeacher.Items.Clear();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
}
}
I think what I really need to do is make a for loop and have it iterate for the amount of teachers that are in the list, and then have it populate the list, but not sure how exactly to do this.
It is hanging up on the ds part each time. I know the databind is causing it so this is why I thought perhaps better to iterate this? Any help would be appreciated.
The values from the first list are in the tblEmployee for "T" Teachers that can teach those classes. So that is why I want to 2nd drop down populated with their names. Thanks!
|
|
|
|
|
WickedFooker wrote: strSQL = "select * from tblEmployee where canTeach=" + Teachable;
Your first problem is SQL Injection[^]. Never use string concatenation to insert parameters into a query; use a parameterized query instead.
WickedFooker wrote: dbCmd = new OleDbCommand(strSQL, dbConn);
DataSet ds = new DataSet();
dbConn.Close();
Creating an OleDbCommand object isn't going to execute the query, let alone store the results in another variable. You could use ExecuteReader , iterate through the results, and add them to a DataTable , but it's much simpler to use a DataAdapter to do the work for you.
WickedFooker wrote: if (ddlTeacher.SelectedValue == "0")
{
ddlTeacher.Items.Clear();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
}
Since you've just inserted an item with a value of "0" as the first item, this will most likely be the selected item. Even if your data-binding was working, this block of code will most likely throw away the results from the database and leave you with an empty list.
Try something like this:
protected void ddlcourseType_SelectedIndexChanged(object sender, EventArgs e)
{
string path = Server.MapPath("eAcademy_DB.mdb");
string connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
string commandText = "SELECT * FROM tblEmployee WHERE canTeach = ?";
var ds = new DataSet();
using (var connection = new OleDbConnection(connectionString))
using (var command = new OleDbCommand(commandText, connection))
{
command.Parameters.AddWithValue("@p0", ddlcourseType.SelectedValue);
var adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
}
ddlTeacher.DataSource = ds;
ddlTeacher.DataTextField = "emp_ID";
ddlTeacher.DataValueField = "emp_ID";
ddlTeacher.DataBind();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I just want to thank you for the help! This did the trick. I was able to populate the 2nd table with perhaps the smallest of changes.
string commandText = "SELECT * FROM tblEmployee WHERE canTeach = " + ddlcourseType.SelectedValue;
I removed the select on the bottom and instead put it in the page load since it is more needed for looks when the page loads. Thanks again for your help. I am certain I will be back for more
REVISED: I see your warning about String concatenation. I will change it back. I went back to the way you originally posted it!
modified 20-May-13 16:56pm.
|
|
|
|
|
i think you are missin to fill your dataset your command object not executing use
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(dbCmd)
adapter.Fill(ds);
after
dbCmd = new OleDbCommand(strSQL, dbConn);
then it fill dataset and your debug will show your dataset contain value.
|
|
|
|