Books for asp.net

Thursday, January 10, 2008

etrieve the multiple selected items in a CheckBoxList?

Dim strchklist As String = ""

Dim li As ListItem
For Each li In CheckBoxList1.Items
If li.Selected Then
strchklist += li.Text + " "
End If
Next
If strchklist = "" Then
Response.Write("No item Selected")
Else
Response.Write(("You selected : " + strchklist))
End If

Thursday, January 3, 2008

useful link

http://sapid.sourceforge.net (xml cms)
http://www.own-free-website.com (free hosting)
http://blogs.msdn.com/jamesche/archive/2007/09/27/automating-aspnet-compiler-in-visual-web-developer.aspx
http://www.codeplex.com/PUMA

Wednesday, September 19, 2007

Gridview Delete

Protected Sub gv1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gv1.RowDeleting

Dim row As Integer
row = e.RowIndex
Dim idx As String = gv1.Rows(row).Cells(0).Text

Dim cmd As SqlCommand = conn.CreateCommand
Dim ds As New DataSet
cmd.CommandText = "Delete from login where id = " + idx.ToString + ""
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()

bind_grid()

End Sub

Gridview Paging

Protected Sub gv1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gv1.PageIndexChanging
gv1.PageIndex = e.NewPageIndex
bind_grid()
End Sub

Monday, September 10, 2007

Upload picture

this source code will get the image size, image dimension, image type and save to folder

If FileUpload1.HasFile = True Then
If Round(FileUpload1.PostedFile.ContentLength / 1000) > 100 Then
Label1.Text = "Uploaded file size must be less than 100 KB"
End If

Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "
" & _
"File Size: " & _
Round(FileUpload1.PostedFile.ContentLength / 1000) & " kb
" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType & _
"Image Dimensions :" & _
GetSize(FileUpload1.PostedFile.InputStream, "").ToString
FileUpload1.PostedFile.SaveAs(Server.MapPath(FileUpload1.PostedFile.FileName))
Else
Label1.Text = "Please select file"
End If