|
Maybe google can help you?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Member 4756709 wrote: is there any way by which voice.speak method once begun ended even before completing the reading of the whole document.
Yes. See this[^] article.
/ravi
|
|
|
|
|
I have a nested repeater that I am trying to sum totals entered by a user, the code behind and repeater code is below. I get a null reference exception: an object reference not set to an instance of an object. the error is at: (((TextBox)parent.FindControl("TextBox2")).Text) = Convert.ToString(compPercent);
How can I get to this control to update, or add a label here?
public void AddComponent(object sender, EventArgs e)
{
int compPercent = 0;
foreach (RepeaterItem repItm in parent.Items)
{
foreach (Control childControl in repItm.Controls)
{
Repeater childRepeater = childControl as Repeater;
if (childRepeater != null)
{
foreach (RepeaterItem child in childRepeater.Items)
{
foreach (Control childControl2 in child.Controls)
{
CheckBox chk = childControl2 as CheckBox;
if (chk != null)
{
if (chk.Checked)
{
//get percent entered
compPercent = compPercent + Convert.ToInt32(((TextBox)child.FindControl("capabilitiesPercentEntered")).Text);
(((TextBox)parent.FindControl("TextBox2")).Text) = Convert.ToString(compPercent);
}
}
}
}
}
}
}
}
ASP Page:
<asp:repeater id="parent" runat="server">
<itemtemplate>
<tr>
<td width="50px"><b>Select</b></td>
<td width="350px"><b><%# DataBinder.Eval(Container.DataItem,"PSO") %></b></td>
<td><b>Enter %</b></td>
</tr>
<asp:repeater id="child" datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>' runat="server">
<itemtemplate>
<tr>
<td><asp:CheckBox ID="CheckBox2" runat="server" />
<asp:HiddenField ID="hidden" runat="server" Value=<%# DataBinder.Eval(Container.DataItem, "[\"PSOComponent_id\"]" )%> /></td>
<td><%# DataBinder.Eval(Container.DataItem, "[\"PSOComponentName\"]")%> </td>
<td><asp:TextBox ID="capabilitiesPercentEntered" Width="40px" runat="server" OnTextChanged= "AddComponent" AutoPostBack="true" /></td>
</tr>
</itemtemplate>
</asp:repeater> <br />
<tr>
<td></td>
<td>Percent Total: </td>
<td><asp:TextBox ID="TextBox2" runat="server" Width="40px" Text="test text"></asp:TextBox></td>
</tr>
</itemtemplate>
<SeparatorTemplate>
<tr><td colspan=3><hr /></td></tr>
<SeparatorTemplate>
</asp:repeater>
</table>
|
|
|
|
|
Try putting your code in <code></code> blocks, and it will be easier for people to read.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
How does one issue an MS-DOS command from a C# program? I want to write a program that issues a command in every sub-directory from a specified directory.
This is written as a Windows application, not a console application.
Thank you,
Glenn
|
|
|
|
|
|
Look at System.Diagnostic and Process...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Given the following class hierarchy:
public class A
{
public virtual void func();
}
public class B : A
{
public override void func();
}
public class C : B
{
public override void func()
{
base.func();
}
}
How can my class C , call the func() implementation in the base class A .
In C++ this could be done by simply specifying the name of the base class, A::func() , but how can I do this in C#?
Thanks for your help.
|
|
|
|
|
this.func(); will always call the "highest" function it can
|
|
|
|
|
Which is very naughty and therefore not allowed in C#.
Hmmm... will ((A)this).func() do it? I'd better go check.
Nope.
modified on Friday, January 18, 2008 9:09:34 PM
|
|
|
|
|
PIEBALDconsult wrote: Hmmm... will ((A)this).func() do it?
No, it will just recurse.
|
|
|
|
|
So I see. Good. I even tried
public class C : B
{
public override string
func
(
)
{
return ( (string) typeof(A).GetMethod
(
"func"
,
System.Type.EmptyTypes
).Invoke ( this , null ) ) ;
}
}
and it still recursed (as it should).
|
|
|
|
|
PIEBALDconsult wrote: Which is very naughty and therefore not allowed in C#.
Yeah, that's kind of what I thought...
I was beginning to think things were getting a little out of hand, and you've just confirmed it. Time to refactor this particular section, before one of my co-workers posts it to Coding Horrors!
|
|
|
|
|
Hello everyone.
I'm back, and that means... yes, in my ongoing attempts to self-learn C# and .NET, I have once again painted (or coded) myself into a corner.
I managed to write a bunch of code and now find that it needs to be able to do an invalid casting in order for me to proceed. Basically, I have created a class (let's say "Automobile") and other classes ("Truck" and "Van") that are derived from it.
Unfortunately I find my self in the situation where I created
Automobile rentedCar = new Automobile();
but now I need to use rentedCar as a Van. However
Van myWheels = (Van)rentedCar;
is illegal.
I have to create rentedCar first [so that I can rentedCar.DriveHome() ], but I do not know ahead of time whether I will be trying to use rentedCar as a Van or a Truck - depends on whether the kids have a soccer game [myWheels.PlayDisneyDVD() ] or if a friend is moving [myWheels.DropTailgate() ] .
Could someone point me in the right direction for solving this please? Is this what generics are for?
I know, in your world you determine the type of vehicle you want and then rent it. But in my world, we rent it first, drive it home and then decide what kind of vehicle we want it to be - and we like it that way!
Clive Pottinger
Victoria, BC
|
|
|
|
|
You cannot cast it because you've create the "basic" automobile definition which knows nothing about how a van operates.
The easiest way would be to create a new van accepting an Automobile in it's contructor through which you can "copy" stuff across.
|
|
|
|
|
Have your kids and friends decide before you go and rent a car, then rent the
appropriate vehicle.
You can't transform a general-purpose car into a specialized one, but you can ignore
the specialization of a vehicle and concentrate on its general-purpose characteristics.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
It seems to me that your Automobile class should have a DriveHome() method. Since the classes Truck and Van are derived from Automobile, they would be able to use the DriveHome method declared in Automobile.
If the outcome of DriveHome() is going to be different depending on whether your object is a Truck or if it is a Van, then in your Automobile class, when you declare your DriveHome() method, declare it as virtual
public virtual void DriveHome()<br />
{<br />
}
Then, in your Truck class for example you could override the DriveHome() method to customize it specifically for the Truck's situation
public override void DriveHome()<br />
{<br />
if (IAmHelpingFriendMove)<br />
{<br />
}<br />
<br />
base.DriveHome()<br />
}
Hope that helps you out a bit...
|
|
|
|
|
cpotting wrote: I know, in your world you determine the type of vehicle you want and then rent it. But in my world, we rent it first, drive it home and then decide what kind of vehicle we want it to be - and we like it that way!
Well maybe you need to wrap your basic auto in a van or pickup envelope,
Auto auto = new Auto() ;
auto.DriveHome() ;
switch ( typeofvehicleneeded )
{
case VehicleType.Van : return new Van ( auto ) ; break ;
...
}
van.CommitDriveByShooting() ;
auto = van.Auto ;
van.Dispose() ;
auto.Getaway();
auto.Return();
Either way you should read up on interfaces.
|
|
|
|
|
Thanks everyone. It would appear that the general consensus is "You're screwed, pal!".
That's okay. I think I have a way out of this akin to Ed.Poore's suggestion that the Van and Truck construction methods should accept an Automobile object and derive the required information from that.
Thanks again.
If I can't get it to work, I'll be back.
Clive Pottinger
Victoria, BC
|
|
|
|
|
This is the problem, i have a ocx, that have one control and one uint Property, like this
Property color, acept values uint, Manually i set the value as this:
object.color = 0xFFFFFF;
for wythe color, i want to set the color using:
ocxObject.color = colorDialog1.Color; /// this is the error
and i get the error, because the ocxObject.color only acept uint
i make the convertion:
ocxObject.color = (uint)(colorDialog1.Color);
and not have error in code but, the colors not Match.
any solutions thanks
|
|
|
|
|
Hi,
not sure but I think you should try
ocxObject.color = colorDialog1.Color.ToArgb();
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello there,
I´m writing a database application with ADO.net to manage my contacts.
I have a DataGridView DGVFriends on my Form that I want to connect to the Table "tblFriends" in my DataSet ds.
So far my code simply is:
DGVFriends.DataSource = ds.Tables["tblFriends"]
the problem is that all the columns in "tblFriends" are shown. For example ID, even though this is only the primary key and the user won´t be interested in it. so i want to omit it´s display in the dataGridView.
The second problem is:
in the same dataGridView I want to add a column that displays the full name of my contact and therefore is compound of the three columns name, middleName and lastName that are also in tblFriends.
Any ideas??
Thanks for help, useful links etc.
der gunnar
|
|
|
|
|
dergunnar,
Adapt the SQL your executing, eg: select name, lastName from tblFreinds;
You can also concat values using SQL.
Regards,
Gareth.
|
|
|
|
|
This should get you going (code not tested for accuracy).
<asp:GridView ID="UserGrid" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="First Name" />
<asp:BoundField DataField="MiddleName" HeaderText="Middle Name" />
<asp:BoundField DataField="LastName" HeaderText="Last Namwe" />
<asp:templatefield headertext="Full Name">
<itemtemplate>
<asp:label id="FullNameLabel" Text='<%# Eval("FirstName") +
Eval("MiddleName") + Eval("LastName")%>' runat="server"/>
</itemtemplate>
</asp:templatefield>
</Columns>
</asp:GridView>
|
|
|
|
|
Okay,
I should have asked a little more specific. The problem is I´m not working with a databasee. I just read an xml file into the dataset. since it is a local application that´s the easiest way to go.
the next thing is that I want to work with all the columns in the DataTable. that means that in the Datatable the columns ID, Name, middleName... ahould be present. not loading them doesn´t help me.
my problem really lies between the dataTable (already in memory) and the DataGridView.
A workaround for the compound name column that came to me is to create a column FullName in tblFriends. so the only problem would be to prevent the rest of the columns from being displayed n the DataGridView.
Thanx for your help so far!!!
der gunnar
|
|
|
|