Expand|Select|Wrap|Line Numbers
- Protected Sub ButtonAddFile_Click(ByVal sender As Object, ByVal e As EventArgs)
- Dim gv As New GridView
- gv.Style.Add("position", "absolute")
- gv.Style.Add("left", "575px")
- gv.Style.Add("top", "220px")
- gv.EnableViewState = False
- form1.Controls.Add(gv)
- gv.DataSource = GetDataTable()
- gv.DataBind()
- Dim lbl As New Label
- lbl.Style.Add("position", "absolute")
- lbl.Style.Add("left", "575px")
- lbl.Style.Add("top", "20px")
- End Sub
- Private Function GetDataTable() As DataTable
- Dim doc As New DataTable("Document")
- Dim id As New DataColumn("Document")
- id.DataType = GetType(String)
- id.Unique = True
- id.AllowDBNull = False
- id.Caption = "Document"
- doc.Columns.Add(id)
- Dim filing As New DataColumn("Type")
- filing.DataType = GetType(String)
- 'filing.MaxLength = 35
- filing.AllowDBNull = False
- doc.Columns.Add(filing)
- doc.PrimaryKey = New DataColumn() {id}
- 'add data to data table
- Dim newdoc As DataRow = doc.NewRow()
- newdoc("Document") = FileToUpload.PostedFile.FileName
- newdoc("Type") = listDocType.SelectedValue
- doc.Rows.Add(newdoc)
- Return doc
- End Function
2. Also If I have to add a delete button of GridView , what code should i write so that it deletes that particular row every time i click delete