|
hi all
i want to list all of the logged in users on a page , i did it fine
but i have a problem when the user close the browser i cant remove them from the list,
how can i get use of Session_End in the Global.asax .
this code is in Global.asax
private Code.BL.Users.SysUserCollection users = new Code.BL.Users.SysUserCollection();
public Code.BL.Users.SysUserCollection OnLineUsers
{
get { return users; }
set { users = value; }
}
this code is in BL
public class SysUserCollection : IList<SysUser>
{
List<SysUser> users = new List<SysUser>();
#region IList<SysUser> Members
public int IndexOf(SysUser item)
{
return users.IndexOf(item);
}
public void Insert(int index, SysUser item)
{
throw new Exception("The method or operation is not implemented.");
}
public void RemoveAt(int index)
{
users.RemoveAt(index);
}
public SysUser this[int index]
{
get
{
return users[index];
}
set
{
users[index] = value;
}
}
#endregion
#region ICollection<SysUser> Members
public void Add(SysUser item)
{
if (!this.Contains(item))
{
users.Add(item);
}
}
public void Clear()
{
users.Clear();
}
public bool Contains(SysUser item)
{
foreach (SysUser user in users)
{
if (user.UserId == item.UserId)
return true;
}
return false;
}
public void CopyTo(SysUser[] array, int arrayIndex)
{
throw new Exception("The method or operation is not implemented.");
}
public int Count
{
get { return users.Count; }
}
public bool IsReadOnly
{
get { throw new Exception("The method or operation is not implemented."); }
}
public bool Remove(SysUser item)
{
foreach (SysUser user in users)
{
if (user.UserId == item.UserId)
{
return users.Remove(user);
}
}
return false;
}
#endregion
#region IEnumerable<SysUser> Members
public IEnumerator<SysUser> GetEnumerator()
{
return users.GetEnumerator();
}
#endregion
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
thx
|
|
|
|
|
hi guys ,
i have to implement pre/next with numeric mode
like 1 2 3 4 5 next
pre 6 7 8 9 10 next
please tel me how to implemt this with complete discriptin ,as i am very new to custom paging
|
|
|
|
|
Did you ever searched it in google, before posting it over here ?
Have a look[^]
|
|
|
|
|
hi,
Is there a method or third party tool to convert page template to master page.
Thanks in advance.
|
|
|
|
|
What do you mean by "page template" exactly? A standard .aspx?
That's an interesting thought ... I'm assuming you mean if you have 50 pages that all have similar content, you want to (a) scan and extract what is common and (b) update the pages to now point to the master?
What's interesting is that the page designer can be parsed as XML so there is a lot of flexibility there, but I think the problem IMHO would be the references and designer.cs as well.
How large is your application? Sometimes brute force is the way to go, I'd be afraid any utility like that wouldn't be smart enough and I'd end up having to touch at least two or three things on each page anyway.
Jeremy Likness
http://csharperimage.jeremylikness.com/
|
|
|
|
|
plz chk the error in code n reply me
public partial class Default2 : System.Web.UI.Page
{
SqlConnection cnx = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Coupon Management.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlDataAdapter da1 = new SqlDataAdapter();
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand();
DataTable dataTable;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillVendorGrid();
}
}
private void FillVendorGrid()
{
dataTable = new DataTable();
cmd.Connection = cnx;
cmd.CommandText = "SELECT Coupon_Info.RecievingDate, CouponType.CouponName, Coupon_Info.Serial_Start, Coupon_Info.Serial_End, Coupon_Info.Recieved_By FROM Coupon_Info INNER JOIN CouponType ON Coupon_Info.Coupon_TypeID = CouponType.CouponTypeID";
da1 = new SqlDataAdapter(cmd);
da1.Fill(dataTable);
GridView1.DataSource = dataTable;
GridView1.DataSource = ds;
GridView1.DataSourceID = String.Empty;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
FillVendorGrid();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
cmd.Connection = cnx;
cmd.CommandText = "DELETE FROM Coupon_Info WHERE RecievingDate='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "'";
cnx.Open();
cmd.ExecuteNonQuery();
cnx.Close();
FillVendorGrid();
}
}
modified on Thursday, July 2, 2009 5:32 AM
|
|
|
|
|
What is error message?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
IListSource does not contain any data sources
|
|
|
|
|
haleemasher wrote: plz chk the error in code n reply me
Where is the problem?
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
This is the error
Exception Details: System.Web.HttpException: The IListSource does not contain any data sources
|
|
|
|
|
this means your dataset in null
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
how i chk that dataset is empty or not. the table i want to show in gridview has 4 records
|
|
|
|
|
if(datasetname.Tables.Count ==0)
{
}
else
{
}
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
where i put this code sir?
|
|
|
|
|
Check in your previous post your answer "how i chk that dataset is empty or not. the table i want to show in gridview has 4 records"
And if you don't know where to put if condition then how can I know?!
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
You are assiging GridView1's DataSource two times using a DataTable and then a DataSet. Remove the line GridView1.DataSource = ds;
Your code should be like
da1.Fill(dataTable); <br />
GridView1.DataSource = dataTable; <br />
GridView1.DataSourceID = String.Empty;
|
|
|
|
|
thanx it works but give another error in
cmd.CommandText = "DELETE FROM Coupon_Info WHERE RecievingDate='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "'";
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
when i click delete in gridview
|
|
|
|
|
Have you set the DataKeyNames property in the GridView?
Also you are checking DataKey value with RecievingDate columns in the Coupon_Info table.
Therefore check whether you have set RecievingDate to the DataKeyNames property of the GridView
|
|
|
|
|
Hope ma posting in the right place,,,
I have the following:
I installed VS2008, on a vista 64bit machine, on the first run of VS2008, it promots u to select the Enviroment to work in. i selected C++.
My question is, if i wana choose different enviroment like Visual Basic, how can i change the enviroment the next time i run VS2008???
Best regards,
0 will always beats the 1.
|
|
|
|
|
from file menu select new project it open a dialogue box, left side of that dialogue box have different options of languages u can easily change the environment
|
|
|
|
|
scorp_scorp wrote: Hope ma posting in the right place,,
No, this is not the right forum ! This is Forum for ASP.NET
|
|
|
|
|
Kindly Guide me where i can post for VS2008 issues.
Best regards.
0 will always beats the 1.
|
|
|
|
|
|
Thanks.
0 will always beats the 1.
|
|
|
|
|
how can i get the server HDD Serial No in a web application when it runnin from a client Machine.
and if that is impossible can you give me an idea please.
regards,
Live each day as though u'll die tommorow
|
|
|
|