|
Yes
only two letters away from being an asset
|
|
|
|
|
thanks very much!!
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Hello,
I have an enum:
Public Enum Color
Red
Blue
Green
End Enum
I need:
1. Loop trough all enum items and get each one value (Ex: Red) and index (Ex: 1).
For Each color As Color In [Enum].GetValues(GetType(Color))
???
Next
2. Get an enum value (Ex: Red) by providing its index (Ex: 1)
I tried various options but I am not able to make this work.
Thank you for your Help,
Miguel
-- modified at 15:05 Friday 12th January, 2007
|
|
|
|
|
So what have you tried? Do you get any exception or are the values not what you are expecting?
only two letters away from being an asset
|
|
|
|
|
Hello,
I have the following:
' Loop through each color enumeration name
For Each color As Color In [Enum].GetNames(GetType(Color))
Dim name As String = MyF(color, Thread.CurrentThread.CurrentCulture)
Dim index As Integer = CType(color, Enumeration.District)
Response.Write("Name: " & name & " | Index: " & index.ToString & "<br />")
Next
I think this is working but I am not sure if this is the best way to solve this.
Note: MyF is a function with a Select Case block which returns a string giving a enum element and a culture. I need this.
However, I now need to get the text of an element by giving its index.
For example, get "Red" when I say 1.
Could someone help me out?
Thanks,
Miguel
|
|
|
|
|
enum Colors
{
White,
Red,
Green
}
int x = 1;
Colors color = (Colors)x;
color.ToString() == "Red"
only two letters away from being an asset
|
|
|
|
|
I created a datatable that binds to a gridview. This datatable holds temporary data. The temporary data is address information. I'm stuck on the gridview part, I can append data to it using an add more addresses button but I'm stuck on the delete button code. Since this doesn't have an sqldatasource or objectdata source, what code do I use to have the selected rows deleted?
Here is my code:
Private Function CreateDataTable() As Data.DataTable
Dim myDataTable As Data.DataTable = New Data.DataTable()
Dim myDataColumn As Data.DataColumn
myDataColumn = New Data.DataColumn
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "ID"
myDataColumn.AutoIncrement = True
myDataColumn.AutoIncrementSeed = 1
myDataTable.Columns.Add(myDataColumn)
myDataColumn = New Data.DataColumn
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "Address"
myDataTable.Columns.Add(myDataColumn)
myDataColumn = New Data.DataColumn
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "City"
myDataTable.Columns.Add(myDataColumn)
myDataColumn = New Data.DataColumn
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "State"
myDataTable.Columns.Add(myDataColumn)
myDataColumn = New Data.DataColumn
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "Zip"
myDataTable.Columns.Add(myDataColumn)
myDataColumn = New Data.DataColumn
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "Yrs"
myDataTable.Columns.Add(myDataColumn)
Return myDataTable
End Function
Private Function AddDataToTable(ByVal Address As String, ByVal City As String, ByVal State As String, ByVal Zip As String, ByVal Yrs As String, ByVal myTable As Data.DataTable)
Dim row As Data.DataRow
row = myTable.NewRow
row("Address") = Address
row("City") = City
row("State") = State
row("Zip") = Zip
row("Yrs") = Yrs
myTable.Rows.Add(row)
Return row
End Function
Protected Sub btnaddress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnaddress.Click
panel1.Visible = "True"
End Sub
Protected Sub btnaddresses_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnaddresses.Click
If txtaddress.Text.Trim = "" Then
lbladdresses.Text = "You must fill in a address."
Return
Else
AddDataToTable(Me.txtaddress.Text.Trim, Me.txtcity.Text.Trim, Me.txtstate.Text.Trim, Me.txtzip.Text.Trim, Me.txtyear.Text.Trim, CType(Session("myDataTable"), Data.DataTable))
Me.GridView1.DataSource = CType(Session("myDataTable"), Data.DataTable).DefaultView
Me.GridView1.DataBind()
Me.txtaddress.Text = ""
Me.txtcity.Text = ""
Me.txtstate.Text = ""
Me.txtyear.Text = ""
Me.txtzip.Text = ""
Me.txtyear.Text = ""
End If
End Sub
If Me.IsPostBack = False Then
Dim MyDt As New Data.DataTable
MyDt = CreateDataTable()
Session("myDatatable") = MyDt
Me.GridView1.DataSource = (CType(Session("myDatatable"), Data.DataTable)).DefaultView
Me.GridView1.DataBind()
End If
End Class
|
|
|
|
|
If you don't use any data source control with the GridView, you manually hook up the GridView 's events to do what you need. Here, you can create an event handler for the RowDeleting event, and in this method you can determine the row being deleted using the event argument instance or the control properties, you then can delete the row in your data source. In addition, you can choose to handle the RowCommand event for a button's click in general, for more information and sample code, you can see GridView Members [^]
|
|
|
|
|
I put this code in:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName = "Delete" Then
GridView1.DeleteRow(GridView1.SelectedIndex)
End If
End Sub
End Class
I'm getting an error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
What should I Do?
|
|
|
|
|
There are a couple of things to talk about your sample code here:
+ To get reference to the row index to delete in the RowCommand event, you should use the e.CommandArgument , and e.RowIndex in the RowDeleting event.
+ Basically, calling DeleteRow method makes the two events RowDeleting and RowDeleted get raised, however this code does not make sense in this case as these two events automatically get raised by the control when the CommandName is Delete . So you don't need to call DeleteRow method, instead you should place your code to delete the selected row in the temp data source, then rebind it to control.
+ Like I said above, when the CommandName is Delete, you should use the specific event RowDeleting, put your code to delete the row there, and finally cancel the event.
|
|
|
|
|
This is a stupid question but what should I put in the row command event then?
|
|
|
|
|
Thanks, I figured it out.
|
|
|
|
|
Partial Class RecruitingApp
Inherits EmailReadyPage
I'm receiving an error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30554: 'EmailReadyPage' is ambiguous.
Source Error:
Line 7:
Line 8: Partial Class RecruitingApp
Line 9: Inherits EmailReadyPage
Line 10: Private okToSendMarkup As Boolean = False
Line 11:
I'm using a different class to render a gridview to email the gridview results. I'm receiving this compilation error. Any suggestions?
|
|
|
|
|
Looks like you got a name conflict. Can you check that the name "EmailReadyPage" is also defined somewhere else? You may try with the fully qualified name of the class.
|
|
|
|
|
That's what it was. A naming conflict with another web form. Thanks
|
|
|
|
|
:-DHello there,
I would like to ask how can I code in aspx.vb page the data that is entered into the text box (a web control)by a user, and when the data is entered in the text box, the user will press the submit button to send the entered data into the table in the database!
please tell me how to do this in a full procedure .. because I really would like to learn (^_^)
I would like to have visual basic coding in aspx.vb and not in HTML.
It is very urgent ... I am waiting for your reply (^_^) I will appreciate your kindly assistance.
VB Student (New Learner - Home Alone)
|
|
|
|
|
You can pick up an ASP.NET book to start or any of lots of tutorials out there. MSDN[^] and Stater Kits[^] can get you started.
|
|
|
|
|
How do you all go about monitoring memory usage on your IIS 6 servers? We're using ASP.NET 1.1 on Win2k3 boxes with 2GB of RAM.
Do you set up performance counters? Do you have applications that monitor memory usage and alert you when it exceeds a certain level? Any pointers to articles/books/whatever that deal with this?
Thanks!
|
|
|
|
|
Google: "Monitor memory usage" Server
I won't promote the product that my company uses but there are probably hundreds of them
led mike
|
|
|
|
|
led mike wrote: Google: "Monitor memory usage" Server
Thanks, did that, but I'm looking for specific recommendations from the experts here, and not necessarily from the Intertubes at large.
|
|
|
|
|
Hi Everyone,
I want all of you to know that
I've fallen in love with ATLAS. I really have. Somebody help me,
I'm in love with ATLAS and am completely infected.
Help!
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
it is definitely a great addition, but there are some pitfalls. You'll soon find a few, then start looking for workarounds.
|
|
|
|
|
Dear All,
i am making web application using asp.net ,C# (Visual studio 2005).i have a web page with couple textbox control that i used to fill date from calender controls.
that is ont textbox is start date and other one is end date. In order to check whether end date is not less then start date . i am using compare validator.
i work fine with normal format but when i change my format to dd/MM/yyyy, It causes problem . that is even i have end date greater then start date. it then also give error message
it work with following format
string str = Calendarstartdt.SelectedDate.ToString("d",DateTimeFormatInfo.InvariantInfo);
but this format show me date as mm/dd/yyyy and i need to show date as dd/mm/yyyy so i change the format as
string str = Calendarstartdt.SelectedDate.ToString("dd/MM/yyyy"); its show ok. but comparevalidator show error message
even if date is greater
Please guide me where i am going wrong.
thanks
regards
imran khan
|
|
|
|
|
Hey peeps,
I have a problem i would like help with.
I have created a webhandler i use for displaying images, its ProcessRequest looks like this.
public void ProcessRequest(HttpContext context)
{
HttpResponse response = context.Response;
HttpRequest request = context.Request;
response.ContentType = "image/jpeg";
response.Cache.SetExpires(DateTime.Now.AddDays(7));
response.Cache.SetCacheability(HttpCacheability.Public);
response.BufferOutput = false;
writeSingleImage(Convert.ToInt32(request.QueryString["ImageID"]), Convert.ToInt32(request.QueryString["Size"]), response.OutputStream);
response.End();
}
The writeSingleImage function just retrieves the image frmo the database and writes it out to the response.
No i have made users able to rotate images, but since the webhandler caches images they wont be able to see changes until their cache expires.
So i want to remove a single cached image when users rotate that image. Hov do i do this. All i done to cache the image is what you see in the ProcessRequest above.
Hope somebody have an idea, because i really dont know too much about caching.
-Anders, DK
|
|
|
|
|
The image is being cached in either the browser's cache or their proxy server's cache (HttpCacheability.Public). So the cache must be cleared by the client. You *might* be able to get around this by adding a random value to the parameter string of the url they use to request the new image. So when they submit the GET request it looks something like this:
?ImageID=34&Size=500&noCache=342
You never have to check the "noCache" parameter, but the browser probably will make the request instead of pulling it from cache because the url has changed.
|
|
|
|