|
What I wish for is a method to be called each time a row is created that will take the text in a specific column and convert it.
Table:
Row Name Id
1 Ric 123
2 Lou 456
3 Matt 789
As a row is created a method takes the Id, runs it through a custom method I have (for converting ID's into Usernames) and then displays the username instead. I am using a SPGridView (SharePoint Grid View).
|
|
|
|
|
I think there is an event called OnItemDatabound that gets called for every row as they are populated.
|
|
|
|
|
Hi All,
I created a web application which creates(for the first time) and writes to a log file using Log4Net tool.
Now my requirement is to clean the data for 60 days old log data.
Can any tell me how to do this.
Thanks in advance,
urs friend
|
|
|
|
|
Did you look if Log4Net havent got this option already?
|
|
|
|
|
Thanks for the response
but i did not find the option in log4net ( i am new to log4net)
|
|
|
|
|
If you set your log file to be a rolling file appender, then you could just archive off any data in a log file that is older than 60 days.
|
|
|
|
|
Can you explain how to set(or what are the settings need to be set) the log file to be a rolling appender, to archive the data in a log file which is older than 60 days
Thanks,
|
|
|
|
|
Hi,
I don´t know log4net, it´s easy to do it (logs) with sql Store procedures i can help there if you want.
|
|
|
|
|
Hi,
I have several excel file with the same design, but with different content. The files are containing two sheets. Now I want to import from each file the first sheet en put al the sheets into one new excel file. What is the most easy way to do this. Are there any sheet objects in c#.
Regards,
Omy
|
|
|
|
|
Hi,
Do you have Visual Studio 2008 professional edition?
In code project there are some articles with classes to edit MS excel more easyer.
Good Luck
|
|
|
|
|
I 've got VS 2005. I am looking for a code snippet wich can load an compleet active sheet from a excelfile to an another excelfile.
|
|
|
|
|
I have a method which takes a DataRow as an out argument. The method fills out the DataRow with data, and returns it.
So,
public CreateTheFancyTable()
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("First_Column", System.Int32);
DataColumn dc2 = new DataColumn("Second_Column", System.String);
dc1.AllowDBNull = false;
dc2.AlllowDBNull = false;
DataRow dr = dt.NewRow();
bool fSucceeded = FillOutMyRow(dr);
}
public bool FillOutMyRow(DataRow dr)
{
dr["First_Column"] = 1;
dr["Second_Column"] = "";
}
Please don't focus on the bugs in my quick sample here, the real code is a lot more complex than this.
Now, the last line is going to fail, because dt.Columns[dc2].AllowDBNull is false.
How, in the code of FillOutMyRow(), can I find out the properties of the columns in the row that was passed to me? I only know how to get the column properties of a table, and I don't have the table.
Can I refer directly to the column properties of a row (and if so, how?)? Or do I need to get the parent container of the row (the table), and if so, how?
Thanks,
Joe
|
|
|
|
|
DataRow has a Table property.
|
|
|
|
|
Thanks for the help. Of course, I figured that out about 5 seconds after clicking "Post"
I always assume the more complex answer first (I was starting to research "parent containers" when I noticed Table sitting there...)
|
|
|
|
|
JoeRip wrote: Now, the last line is going to fail, because dt.Columns[dc2].AllowDBNull is false.
No it wont, you're setting the value to an empty string not DbNull.Value.
Anyway, you should be able to go back to the table/columns from the datarow.
dr.Table.Columns
so you could do if(dr.Table.Columns["Second_Column"].AllowDBNull) { ... }
|
|
|
|
|
Meanwhile, I'm stuck on the fact that I can't test the passed in DataRow to see if it's null or not..
given
public bool FillOutMyRow(out DataRow dr)
{
if (dr == null)
{
return false;
}
dr["first_column"] = 1;
return true;
}
The compiler is complaining: "use of unassigned parameter dr"
What's the problem here?
|
|
|
|
|
|
Do you actually need ref? DataRow being a class isnt it passed in by reference in any case?
|
|
|
|
|
Why have you changed the param to an out? That wasn't there in your original post!
|
|
|
|
|
That's true, it wasn't. My original post was a quick and dirty bit done from memory, and therefore incomplete.
Are you saying that ref or out is not required here at all? I can pass a DataRow and modify it to my heart's content?
I did test out "ref" when "out" failed, and that does work. Still not sure why "out" doesn't work in the "if (dr == null) case, but it's not clear to me what "unassigned" means here when the caller has already assigned a value to the variable...
|
|
|
|
|
the ref keyword forces the argument to be passed by reference, it has no effect on reference types such as DataRow, but consider the following example with a value type:
static void Main()
{
int i = 1;
NoRef(i);
Console.WriteLine(i);
WithRef(ref i);
Console.WriteLine(i);
}
static void NoRef(int i)
{
i = i +1;
}
static void WithRef(ref int i)
{
i = i + 1;
}
as for the out keyword, this means that the method itself has to set the value of the param before using it. Hence why you cant check it for null before initializing it to some value.
static void Main()
{
int i = 0;
SetOut(out i);
Console.WriteLine(i);
}
static vouid SetOut(out int i)
{
i = 1;
}
So to cut a long story short, just remove the out/ref keyword altogether from your method. You can still change the values of your DataRow within your method.
|
|
|
|
|
Hello,
I want to develop small application for Desktop Sharing if you provide me any example or any link will be good for me.
Thanks
Best Regards,
Chetan Patel
|
|
|
|
|
Look at the source code of VNC, I am sure that will scare you off, as this is no small feat.
|
|
|
|
|
i planning to create a web base vb script editor by c#
but i have no idea about this....
have any suggestion how to create it??
can i apply msscript.ocx for this editor?
|
|
|
|
|
how to insert float value from string into sql from C# .net in float column in database. It should accept only the given decimal point.
Ashok
|
|
|
|