|
Utini wrote: why if (control == TextBox) generates an error - can anyone illuminate me?
Because it's suppose to be: control.GetType()==typeof(TextBox)
|
|
|
|
|
Utini wrote: Well here's a case of "Read the Flipping Manual", if ever I saw one!
Exactly, RTFM. Your code if( control == TextBox) does not and should not compile for several reasons.
1) TextBox is meaningless by itself. typeof(TextBox) means something.
2) Assuming you use the code provieded (1), it is meaningless to check for equality between a Control and a Type. What on Earth would that mean?
Josh
|
|
|
|
|
The is operator checks if the object is (or inherits from) a specific class.
(control is TextBox) does the same as Type.GetType("System.Web.UI.WebControls.TextBox").IsInstanceOfType(control) .
---
b { font-weight: normal; }
|
|
|
|
|
Nader Elshehabi wrote: if(anotherTextBox.GetType().AssemblyQualifiedName == "System.Windows.Forms.TextBox")
Thats an awful way to check whether a control is a textbox, as is the title of this thread the correct way is using the is operator, or again as above the typeof() method
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Ouch!!
Sometimes I screw things up -BADLY-, "Lack of coffee" syndrom I suppose.
Thanks for the tip though.
|
|
|
|
|
control is an instance, TextBox is a type. Apples and oranges (or more correctly, cookies and cookie cutters).
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Hi, I'm creating a control that contains some panels. I want to when the windows form designer manipulates the control, I would place items in these subpanels, like a SplitContainer do with their panels. And, I can do these with button, too? Can click a subbutton of a control and do something, like do the TabControl when clic to select the current TabPage.
Thanks
|
|
|
|
|
I'm trying to create a form that lets me select the item from a list, then click "edit" and a new form opens with the selected record from the previous list and displays that records attributes. I can't figure out how to do this without editing the SQL query to accept a parameter. That wont work for my purpose because I need the user to be able to add/delete from that table, and sql search will only return the 1 item.
Logic Flow:
-User picks item from SQL driven listbox.
-Clicks "Edit", value passed for selected listbox item.
-new form loads (should be on current record, not record 1 which requires the user to navigate back and forth to find the right item.)
I've passed the information needed to the new form, and I know that is making it correctly. I am just not finding any kind of "jump to record" type command for the binding navigator, or the binding source.
Thanks.
|
|
|
|
|
Hello,
How do you get the actual point where the mouse clicked on a form during an onclick event. Here is what I have so far, but it doesn't work...
<br />
private void split_Panel2_Click(object sender, EventArgs e)<br />
{<br />
Point clickPnt = new Point();<br />
clickPnt = (Point)sender;<br />
}<br />
Thanks for your help!
RC
|
|
|
|
|
Handle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);
|
|
|
|
|
it worked!
Thanks for your help!
|
|
|
|
|
Josh Smith wrote: Handle the MouseDown event and cache a Point variable which you can use in the Click handler.
In the Click event handler you can also use the static property Control.MousePosition . Much easier .
Alternatively, controls also have a MouseClick event which gives you the position of the mouse during the click in de event handler argument.
|
|
|
|
|
I was under the impression that he wanted to know where the mouse cursor was when the click process began (i.e. when the button was depressed). Checking Control.MousePosition is good if he wants to know the cursor position after the mouse button is released (MouseDown + MouseUp = Click). I suppose he didn't state either one specifically.
Cheers,
Josh
|
|
|
|
|
I am using the Microsoft SQLHelper.cs class for my data connections. The user enters a part number, clicks a command button and the grid should load with that data. When I pass the parameter I cannot get the grid to populate. I have been working on this since Friday.
Here is my DataBind:
private void BindData()<br />
{<br />
strPartNumberInputReference = txtSearchPart.Text;<br />
ds = new DataSet();<br />
SqlParameter param = new SqlParameter("@PartID", strPartNumberInputReference); <br />
ds=SqlHelper.ExecuteDataset(this.connectionString, CommandTYpe.StoredProcedure,"dbo.GetPartInfoTest", param);<br />
Session["ds"]=ds;<br />
dt = ds.Tables[0];<br />
Session["dt"]=dt;<br />
dgParts.DataSource=dt;<br />
dgParts.DataBind();<br />
txtSearchPart.Text = "";<br />
<br />
}
I played around with the bolded line, and if I don't pass a parameter, all the stuff populates as expected.
In my stored procedure I have the following:
CREATE PROCEDURE [dbo].[GetPartInfoTest]<br />
<br />
@PartID varchar<br />
AS<br />
SELECT c.cost, ct.Description AS ctDescription, pt.description, pt.ID as PartTypeID, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath<br />
FROM costs c INNER JOIN Parts p ON c.PartID = p.Id <br />
INNER JOIN PartTypes pt on pt.ID = p.PartTypeID <br />
LEFT JOIN DraftingData dd on dd.PartID = p.ID LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId<br />
<br />
where p.PartNumber = @PartID<br />
<br />
GO
Again, played around with this and changed @PartID to an actual part number and it populated fine.
I tried the debugger and it compliles fine. It says it takes the parameter and runs through the AttachParameters method (for those of you familiar with SQLHelper). But somehow it must be getting lost and the grid does not populate.
Page Load code:
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
<br />
if(Page.IsPostBack)<br />
{<br />
BindData(); <br />
<br />
<br />
}<br />
<br />
} Command button click code:
private void btnSearchPart_Click(object sender, System.EventArgs e)<br />
{<br />
BindData();<br />
}
Can someone please walk me through this to get this stupid thing to populate? At one point I got it to populate with three blank lines. Now I'm not getting anything.
|
|
|
|
|
leckey wrote: @PartID varchar
leckey wrote: where p.PartNumber = @PartID
p.PartNumber is a varchar field?
Isn't this ASP.NET? Why don't you ask in there incase you are having a timing problem?
|
|
|
|
|
Yes, it's called part number but it's alpha/numeric. I asked in here since my actual code is in C# so I thought it may be a problem with that code.
|
|
|
|
|
The war still rages, eh?
At this point, I recommend that you get back to basics (no, I don't mean quit your programming job and start farming). If I were you I would create a new app, a test app, which has three things in the GUI: a textbox, a button, and a grid. In the button's Click handler, call into your stored proc. Forget about using the SqlHelper class for now. Eliminate as many variables/unknowns as you can and try to narrow in on what the F is going on!
Best of luck,
Josh
|
|
|
|
|
I'm kind of to that point. I went back to my old one with the SQL stuff in the code behind. That pulls the data beautifully. But I'm trying to add a blank row using this:
DataTable myDataTable = new DataTable();<br />
myDataTable = ds.Tables["Rest"];<br />
DataRow row;<br />
row = myDataTable.NewRow();<br />
row.ItemArray = dt.Rows[0].ItemArray;<br />
row["PartNumber"] = DBNull.Value;<br />
myDataTable.Rows.Add(row);
This gives me
System.IndexOutOfRangeException: There is no row at position 0.
I'm basically trying to create a blank row in the main datagrid. Any ideas oh wise and wonderful Josh?
|
|
|
|
|
leckey wrote: row.ItemArray = dt.Rows[0].ItemArray;
Where did 'dt' come from? Are you certain it has rows (it doesn't look like it does)? Check that out in the debugger.
leckey wrote: I'm basically trying to create a blank row in the main datagrid. Any ideas oh wise and wonderful Josh?
Ommmmmmmmmmmmmmmmm :->
I am not an ASP.NET developer, so I can't really help you much there. I would assume that what you're doing (adding a blank row) should do the trick. If it doesn't work out, try posting to the ASP.NET forum (after checking/googling for a solution first, of course).
Josh
|
|
|
|
|
I was trying different code snippets with different naming conventions and somehow they ended up together. I fixed the stored proc stuff (giving length to varchar) and no difference. I basically have two applications: one with the SQL in code behind, and one with the SQL helper. I get the error or no row on line 0 in both cases. I did post to ASP forum so hopefully someone will pick up on it.
Funny you mention farming. Sean Penn is filming a movie close to my hometown and they did casting this weekend. But they still need people who can drive a combine. I just need a headshot!
|
|
|
|
|
leckey wrote: I get the error or no row on line 0 in both cases.
The problem must be that the table just doesn't have any rows in it. If all else fails, you can create a new DataRow and populate the Columns collection manually. Anyways, why are you trying to set the ItemArray on the new "blank" row if you want it to be blank? Setting the ItemArray will give it values.
leckey wrote: But they still need people who can drive a combine.
I hear that babes love men who drive combines in Sean Penn movies. You'll be a star, baby! Don't forget about me when you're a rich and famous Hollywood star.
|
|
|
|
|
I found about 5 articles on inserting a blank row and this method seemed the best for my needs. That's how he set it up.
Josh Smith wrote: populate the Columns collection manually
nah?
Josh Smith wrote: Setting the ItemArray will give it values
As I mentioned above, this is how the guy did it in his example...and it worked on the northwind database. Of course he was just dumping out records as opposed to filtering like me.
|
|
|
|
|
Ok - but the new row won't be blank. That's all I'm saying.
Cheers,
Josh
P.S. When you're a famous Hollywood combine driver, don't forget the little guys (like me) who helped you get there.
|
|
|
|
|
leckey wrote: @PartID varchar
Shouldn't the varchar have a size assigned to it? e.g varchar(64)
Or does your stored-procedure only take one character as its parameter?
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
Good catch!
|
|
|
|