|
Thanks for solving my one problem.
But I am still facing problem. If I select company name from Dropdownlist it does not showing me corresponding record on the textbox(like customer name,address,phone number and so on.
protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.SelectedItemCombo)
{
DetailsOfRecords();
}
}
protected void DetailsOfRecords()
{
thisConnection.Open();
thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = " SELECT * from Customers where CustomerID=" + this.DropDownList1.SelectedValue;
thisReader = thisCommand.ExecuteReader();
while(thisReader.Read())
{
string strID = thisReader["CustomerID"].ToString();
if(strID == this.DropDownList1.SelectedValue.ToString())
{
this.txtCustomerName.Text = thisReader["CustomerName"].ToString();
this.txtCompany.Text = thisReader["Company"].ToString();
this.txtEmailAddress.Text = thisReader["Email"].ToString();
}
}
}
|
|
|
|
|
hum...
1- if that snippet is in a codebehind, than your class inherits from System.Web.UI.Page which does not contains SelectedItemCombo ). So the question is: what is SelectedItemCombo ?
2- doing sql like that in callbacks is a bad idea
3- doing sql without try{}catch{}finally{} is even worst
4- replace while(thisReader.Read()) with: if(thisReader.Read()): is less confusing. But: why not DataSet ?
5- replace if(strID == this.DropDownList1.SelectedValue.ToString()) with if(strID.Equals(this.DropDownList1.SelectedValue.ToString()))
hope this helps
|
|
|
|
|
Thanks for your help.
bool SelectedItemCombo. Actually I have ready made this program in C#(winform) So where I used it.
Once I remove it from my program in ASP.NEt it is working fine.
Once again Thanks.
|
|
|
|
|
I have a search method that calls it's self until a condition is true. Is this wrong?
private void TriggerSearch()
{
*** other misc code ***
if(!blnTriggerFileWritten)
{
TriggerSearch();
}
}
Thanks.
www.lovethosetrains.com
|
|
|
|
|
It's not wrong, but could cause deadlocks if the condition is never true. Also, recursive functions are less efficient than a while loop because each function call in a recursive function must be added to a method call stack, whereas while loops do not.
while(blnTriggerFileWritten == false)
{
blnTriggerFileWritten = ...;
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Who is Jewish, the Trivia Game!
Judah Himango
|
|
|
|
|
It depends on what you're trying to do. The most readable version of a binary search is recursive. You should however be aware that there's overhead involved in the additional calls and that as a result the recursive version will take longer to execute than the nonrecursive one. If performance isn't an issue however the recrusive version will be easier to understand and maintain.
|
|
|
|
|
Thanks for the input. Was working a 'C' port and the other programmer was surprised that I could call my function from within my function. I will relook at the code and probably impliment your suggestions. Thanks again.
www.lovethosetrains.com
|
|
|
|
|
How could i validate a unicode string
Thanks
|
|
|
|
|
|
Good find.
"
Validating Unicode Characters
Use the following code to validate Unicode characters in a page.
using System.Text.RegularExpressions;
. . .
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Name must contain between 1 and 40 alphanumeric characters
// and (optionally) special characters such as apostrophes
// for names such as O'Dell
if (!Regex.IsMatch(Request.Form["name"],
@"^[\p{L}\p{Zs}\p{Lu}\p{Ll}\']{1,40}$"))
throw new ArgumentException("Invalid name parameter");
// Use individual regular expressions to validate other parameters
. . .
}
}
The following explains the regular expression shown in the preceding code:
^ means start looking at this position.
\p{ ..} matches any character in the named character class specified by {..}.
{L} performs a left-to-right match.
{Lu} performs a match of uppercase.
{Ll} performs a match of lowercase.
{Zs} matches separator and space.
'matches apostrophe.
{1,40} specifies the number of characters: no less than 1 and no more than 40.
$ means stop looking at this position.
"
/\ |_ E X E GG
|
|
|
|
|
Hi all,
can someone post a snippet of code that draws a rectangle of 2x3 inches ? I mean something that on
every Graphics (and then with every sort of dpi) is 2x3 inches.
I'm getting mad whit this....
please help !
thanks.
|
|
|
|
|
I don't see how that would even be possible. To do it, in addition to knowing the size and type of a monitor to get the approximate screen size (ie 17" crt is about 16" usable), you'd need to know the exact position they adjusted the hieght and width controls to. Beyond that, if you did do this you'd create something that was completely unusable for anyone who, for bragging rights or due to poor vision, is using a projection screen as a primary display.
|
|
|
|
|
I don't see why not.
Infact, I've found how to do it:
g.PageUnit = GraphicsUnit.Millimeter;<br />
g.DrawRectangle(Pens.Black, 50, 50, 50, 50);
does exactly what I need: without care of dpi draws in inches/millimeters/whatever.
|
|
|
|
|
I am using Microsoft's Message Queue and want to get the ID of the Message I just placed in the Q. Reading a few of the examples I have found it says you can do a simple:
mq.Send(msg, Ticket);
string id = mq.Id.ToString();
All this does is return me a Guid with all zero's in it.
I open up Message Q and see my package there. The 'Label' on the Package is all zero's, however, the ID is an actual Guid.
I have tried 'Label' instead of 'Id' and still nothing.
I really need to get that ID of that package I just inserted into Q for processing.
Any help would be appreciated.
Steve Welborn
Software Architect
|
|
|
|
|
|
DOH!
Your right, worked great. Thanks leppie!
Steve Welborn
Software Architect
|
|
|
|
|
I made this with xacc ide...
apparently it didn't make it to the clip board. It was really cooL!
/\ |_ E X E GG
|
|
|
|
|
Hello,
I have a string to display in my text box:
this.textBoxAssumedHC.Text = (Convert.ToDecimal(myStr)).ToString("c0");
But on leave event I want to convert it back to decimal value, and because there is a dollar sign in front (provided by "c0") it gives me an error.
Any ideas, because I don't want to use the split function.
Thank you
|
|
|
|
|
If you just need to drop the '$', why don't you just use substring to get a substring containing all the chars except the '$', and then conver that?
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
We are creating a windows desktop application and are wondering if there is a disadvantage performance-wise in using User Controls versus embedding the code into the main form.
Thank you for any feedback you can give,
Anne
|
|
|
|
|
no performance problem especially if you dont have many controls in many DLLs
in another side using user controls have advantage like
Usability and maintainability
MCAD
|
|
|
|
|
I have a nice table that I create and show in a datagrid. The data loads perfectly, and then displays nicely. But I need to do some things with it. For starters, I want to add another column that is for display only. So I've tried to add the column "Date" as shown, but it never shows up in the datagrid.
I also want to be able to set the Date column, which I thought would entail cycling through the rows. However when I try to cycle through the rows (in the foreach statement) nothing happens. The MessageBox.Show never pops up.
Any idea why my new column won't show up and why I can't cycle through the rows of my table?
If there's an easier way to just add a column and dynamically change the entries for each row, let me know. And if there's a way to keep data in the data set/data table and NOT show it in the datagrid, I'd like to know that too (I don't want my primary and foreign keys showing up at all but i need to keep track of them).
Thanks!
strClaimsSQL = this.GetClaimsSQL();
da = new OleDbDataAdapter(strClaimsSQL, strConn);
ds = new DataSet();
ClaimsTable = new DataTable();
da.Fill(ds, "ClaimsTable");
DataColumn claimDates = ClaimsTable.Columns.Add("Date");
claimDates.ColumnName = "Date";
this.dgrClaimsData.DataSource = ds;
this.dgrClaimsData.DataMember = "ClaimsTable";
foreach (DataRow row in ClaimsTable.Rows)
{
MessageBox.Show("This is a row in the Claims Table.", "Testing Output");
int i = 0;
row["Date"] = i.ToString();
i++;
row["Premiums"] = i.ToString();
}
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
The columns Didnt displayed and you can not loop throgh
The Rows because the tables was empty look with me
theStorminMormon wrote:
da.Fill(ds, "ClaimsTable");
Now you filled the DataSet with Data from your table
This why all other Columns displayed in the grid
theStorminMormon wrote:
ClaimsTable = new DataTable();</ i>
Now you Create New DataTable which have not any relation with ds DataSet
So Remove it and write
DataColumn claimDates = sd.Tables["ClaimsTable"].Columns.Add("Date");
claimDates.ColumnName = "Date";
To loop for each row
foreach (DataRow dr in ds.tables["ClaimsTable"]
.Rows)
{
}
I hope this help
MCAD
|
|
|
|
|
I guess I was writing my own reply at the same time that you were writing this one. I just wanted to say thanks for your response. It's kind of you to help out, even though in this case I had figured it out too (usually I don't figure it out on my own).
Thanks!
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
Is there any wya to add the "Dates" column so that it will be the first column in the data grid?
Thanks!
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|