|
According to MSDN[^]:
A procedure cannot detect at run time whether a given argument has been omitted or the calling code has explicitly supplied the default value
You have a few choices. You can overload the method and have a private one with a bool flag:
public void Method()
{
Method(true, 0);
}
public void Method(YourEnum yourEnum)
{
Method(false, yourEnum);
}
private void Method(bool ignoreEnum, YourEnum yourEnum)
{
if(ignoreEnum)
{
}
else
{
}
}
You can use nullable as suggested in an answer above.
You can add a value to the enum Invalid = -1 and use that as the default parameter value.
|
|
|
|
|
< Insert scatalogical humor >
|
|
|
|
|
Hello,
I'm currently developing an Integration Package for VS 2010. When I'm debugging the project, it does normally start an experimental hive that includes my package.
My problem: Changes in *.vsct file does not have an effect on the loaded package [at the hive]. Changes in .cs files are accepted normally to the hive package after debug.
The way I found to fix this is to reinstall the package in the hive, but this is definitly no suitable solution.
Thanks for help.
|
|
|
|
|
here is the aspx code for my page
<asp:GridView ID="examgrid" runat="server" AutoGenerateColumns="false"
AllowPaging="true" OnPageIndexChanging="examgrid_pageindexchanging"
onrowdatabound="examgrid_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Exam">
<ItemTemplate>
<asp:Label ID="quesname" runat="server" Text='<%Eval(Ques_Name) %>'></asp:Label>
<br />
<asp:RadioButton ID="op1" runat="server" Text='<%Eval(Option1) %>' /><br />
<asp:RadioButton ID="op2" runat="server" Text='<%Eval(Option2) %>' /><br />
<asp:RadioButton ID="op3" runat="server" Text='<%Eval(Option3) %>' /><br />
<asp:RadioButton ID="op4" runat="server" Text='<%Eval(Option4) %>' /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
can any tells me how do i can show the values from database into radio buttons and in label which is reside into gridview in a single column
i use that code in c#
for (int i = 0; i <= dt.Rows.Count - 1; i++)
{
string ques = dt.Rows[i][0].ToString();
string opt1 = dt.Rows[i][1].ToString();
string opt2 = dt.Rows[i][2].ToString();
string opt3 = dt.Rows[i][3].ToString();
string opt4 = dt.Rows[i][4].ToString();
examgrid.Rows[i].Cells[0].Text = ques;
RadioButton op1 = (RadioButton)examgrid.FindControl("op1");
RadioButton op2 = (RadioButton)examgrid.FindControl("op2");
RadioButton op3 = (RadioButton)examgrid.FindControl("op3");
RadioButton op4 = (RadioButton)examgrid.FindControl("op4");
op1.Text = opt1;
op2.Text = opt2;
op3.Text = opt3;
op4.Text = opt4;
}
but in tht code radio shows null each one,
can anyone help me in it
modified 18-Dec-12 8:04am.
|
|
|
|
|
You may get a better chance of help in the ASP.NET forum.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hey guys,
Long story short:
I have a number of classes that are structured like this:
class ClassA
{
[WantToCopy]
public Property1 { get; set; }
public Property2 { get; set; }
}
class ClassB : ClassA
{
public Property1 { get; set; }
public Property2 { get; set; }
}
class ClassC
{
public ClassB { get; set; }
public Property1 { get; set; }
public Property2 { get; set; }
}
I am trying copy the ClassA values (marked with a specific attribute) from an instance of ClassB to a new instance of ClassA.
This is what I am doing:
T resp = GetClassC();
var types = resp.GetType().GetProperties();
foreach (var type in types)
{
if(type.PropertyType.IsSubclassOf(this.GetType()))
{
List<PropertyInfo> fields = GetFields(type.PropertyType);
foreach (var field in fields)
{
var value = field.GetValue(resp , null);
field.SetValue(this, value , null);
}
}
}
The problem is I get a TargetException when I try and get a ClassA value from a ClassC instance (which makes sense).
ClassC is a generic type. I don't know anything about the ClassB member.
Does anyone have any tricks that could help me out here? Or will I have to use an interface?
P.S I am keen to keep this code to <= .NET 3.5 if possible.
Thank you,
Mark
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
You're trying to read the value of a property defined in ClassA from an instance of ClassC , which doesn't inherit from ClassA .
Try something like this instead:
Type myType = this.GetType();
List<PropertyInfo> propertiesToCopy = GetFields(myType);
foreach (PropertyInfo property in resp.GetType().GetProperties())
{
if (property.PropertyType.IsSubclassOf(myType) || property.PropertyType == myType)
{
var propertyValue = property.GetValue(resp, null);
if (propertyValue == null) continue;
foreach (PropertyInfo propertyToCopy in propertiesToCopy)
{
var value = propertyToCopy.GetValue(propertyValue, null);
propertyToCopy.SetValue(this, value, null);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard that looks like it will do what I am trying to achieve, cheers mate!
Mark Brock
I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking
|
|
|
|
|
As you seem to have access to the code, why not add a copy constructor or Clone method to ClassA?
|
|
|
|
|
Thanks for your response. That is a good suggestion, but in this particular case I am trying to avoid using that approach.
Much appreciated anyway
Mark Brock
I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking
|
|
|
|
|
hi.i want make a report that have 60 filed.and its very hard to me for make report in crystal report in one page,please help me to make several pages in crystal report.
|
|
|
|
|
You can add page breaks in the design interface in CR (spit)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How can i transfer files from a specified location to my server using FTP.
|
|
|
|
|
Look at the MSDN Sample below:
[^]
|
|
|
|
|
I want to move all the files in the given directory path to server Using FTP.
|
|
|
|
|
Is this a C# question? If not then you just need to use the FTP commands to send the files. If you are trying to transfer through some code then you should take a look at the FtpWebRequest Class[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I see voting still hasn't been restored, so here's a for the post.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Maybe you have to use a foreach loop and different threads to upload the stuff...
foreach(string file in Directory.GetFiles("C:\Temp\FtpUpload"))
{
FTPClass.UploadFile(file);
}
|
|
|
|
|
I have developed master-detail relationship in two grids, but i want in one grid. Is it possible or not in windows Application?
|
|
|
|
|
Mis$Fit wrote: Is it possible or not in windows Application?
It's possible.
------------------------------
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
|
You'll either have to use a 3rd party grid control that supports it or develop you're own (not easy!). The DatGridView doesn't support it.
|
|
|
|
|
As I recall you can have drill-down functionality in a DataGridView, but I haven't tried that since 2005.
You probably don't want any grids at all. Grids are horrible.
If you are just presenting readonly data I recommend a TreeView for hierarchical data.
What is it you are trying to do?
|
|
|
|
|
I'm sure I saw there was a documentation regarding to enum usage.
I'm creating a game children that would involve a person that have enums of face, body, legs, feet, arms, hands. Each of those parts have unique values (i.e. face would have values of "round", "square", "oval").
I'm not quite sure on how to put those enums into "person" object.
Can anyone point out the documentation? Thanks!
(or should I use struct? or the other way?)
modified 16-Dec-12 22:23pm.
|
|
|
|