|
i have a folder with few files in it. I want to get only 3 files which has latest lastaccesstime . can anyone help me out .
|
|
|
|
|
<br />
public class dateTimecompare : IComparer<br />
{<br />
<br />
public int Compare(object x, object y)<br />
{<br />
DateTime datex = (DateTime)x;<br />
DateTime datey = (DateTime)y;<br />
<br />
if (datex == datey)<br />
return 0;<br />
else if (datex < datey)<br />
return -1;<br />
else<br />
return +1;<br />
}<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
SortedList sl = new SortedList(new dateTimecompare());<br />
<br />
System.IO.DirectoryInfo objDI = new System.IO.DirectoryInfo(@"\\YourPath");<br />
<br />
<br />
foreach (System.IO.FileInfo fi in objDI.GetFiles())<br />
{<br />
sl.Add(fi.LastAccessTime, fi.FullName);<br />
<br />
}<br />
<br />
string[] fileList = new string[3];<br />
int FileNo = 0;<br />
<br />
foreach (DictionaryEntry de in sl)<br />
{<br />
if (FileNo == 3)<br />
break;<br />
fileList[FileNo] = de.Value.ToString();<br />
FileNo += 1;<br />
}<br />
|
|
|
|
|
how to connect a string array fileList in the gridview .i am doing it as
GridView1.DataSource = fileList;
GridView1.AutoGenerateColumns = false;
GridView1.DataBind();
on aspx page
<asp:GridView ID="GridView1" AutoGenerateColumns="true" runat="server" ShowHeader="False" GridLines="None" OnRowCommand="GridView1_OnRowCommand" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="Hyperlinkpolicy" runat="server" Text='<%#Eval("fileList") %>' CommandArgument='<%#Eval("fileList") %>' CommandName="button" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
pls help me out .
thanks in advance
-- modified at 2:24 Thursday 15th March, 2007
|
|
|
|
|
Add the items to dataTable and bind the table to the grid.
|
|
|
|
|
It may happen that while running application your files have been changed
You can go with System.IO.FileSystemWatcher class
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
You can Delete this post
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
hi evrybody,
I have to give blind-up and blind-down effects
to asp.net control like panel or to div on mouse over event of panel or div.
but unable to achieve it.I have downloaded effects.js file ,
Should I also use Scriptaculous.js .
Please giuide.
Thank you.
yog
hui gfgh kgdgrt njjn hjgkn
|
|
|
|
|
what does it means by blind-up and down ?
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
|
|
hi all,
i want to redirect the user to a page that indicates that the session has expired.
i added code to the session_end event in the Global.asax class, but it did not work
plz send me the response asap
thanks
abdelhameed81
|
|
|
|
|
You need to use a javascript timer to redirect the user. The Session End Event does not fire on a postback so the browser is not redirected. The Session End Event usually occurs when a "session" hasn't posted back in 20 minutes or however long.
|
|
|
|
|
Another way is
create a thread that will check Session is there or not
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
Thats great, and how would you propose to redirect the user from this thread?
|
|
|
|
|
Hi,
My issue is related to getting data in gridview when I selected a row. Because Always the value comes "".
Firstly I bind the dataset to gridview in code-behind. I didn't use sqldatasource. and in html code about gridview is below(between asp gridview tag):
ID="grd_getdata" runat="server"
OnSelectedIndexChanged="grd_getdata_SelectedIndexChanged"
AutoGenerateColumns="False" DataKeyNames="No">
<columns>
<asp:boundfield datafield="No" headertext="No" readonly="True">
and selectedindexchangedevent code is;
protected void grd_getdata_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = grd_getdata.SelectedRow;
Session["aksesuar"] = row.Cells[0].Text;
}
So the value of row.Cells[0].Text always comes empty. On the other hand I see the value on gridview. Why couldn't I get the value? Where is the wrong?
I hope you know the answer!!! Keep Battling.
|
|
|
|
|
What I like to do to avoid issues with the cell numbers is to use mostly template columns. If you want to reference values in a gridview row, use a template column and the row's findControl method.
<br />
Label lbl = row.findControl(LabelID);<br />
Session["aksesuar"] = lbl.Text;<br />
|
|
|
|
|
Then Your approaches is mostly correct ways!!!
Is this only solution? and Is the html code correct? DoI need the datakeynames in html code?
Thanks for your reply...
|
|
|
|
|
No you don't need datakeynames and I'm not going to say my way is most correct. Every method has advantages / limitations. This is just how I do it.
<br />
<br />
public void GridViewRowDataBound(Object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{<br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{ <br />
Button btn = (Button) e.Row.FindControl("btnYourButton");<br />
TextBox txt = (TextBox) e.Row.FindControl("btnYourTextBox") ;<br />
DataRowView drv = (DataRowView) e.Row.DataItem; <br />
btn.CommandArgument = drv["ID"].ToString();<br />
}<br />
}<br />
<br />
protected void btnYourBUtton_Click (object sender, EventArgs e)<br />
{<br />
<br />
Button btn = (Button) sender;<br />
GridViewRow gvr = (GridViewRow)btn.NamingContainer;<br />
TextBox txt = (TextBox) gvr.FidnControl("btnYourTextBox");<br />
<br />
<br />
}<br />
<br />
<br />
That is just how I would code it, not necessarily the best method.
|
|
|
|
|
Hi ToddHileHoffer,
You're super coder. If your solution is the best, I will use it.
Because it works.
Is this the best way to get value from selected row???
Keep Battling
|
|
|
|
|
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
|
|
|
|
|
|
This is generral error given by SQL Server 2005
There might be any reasone for it
I also faced this problem few days before i tried everything then also it was showing same error
At last i switch OFF the Fire Wall of the operating System of the server then it allowed me
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
rami abd alhalim
|
|
|
|
|
I presume you want to know how to allow a remote connection.
* Open up the SQL Server Configuration Manager.
* In the tree on the left open SQL Server 2005 Network Configuration
* Select "Protocols for [Name of instance]" as apropriate
* On the right you'll see a list of protocols. Ensure that TCP/IP is enabled.
|
|
|
|
|
enabled TCP/IP :the same Error
in SQL Server 2000 not 2005
|
|
|
|