Please help iam trying to use this gridview to search a record a diplay the search results on keypress . my challenge is how can i improve this code to display editable gridview after search on key press thanks in advance .Note: Class,Stream,Student Type are all dropdownlists
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadIf Not IsPostBack Then' Dim cmd As New SqlCommand("SELECT NAME, HOUSE, CLASS, STREAM, SEX, ADMNO, ACCOUNT, STATUS, STDTYPE,ACNOS,Rclass FROM Student")' StudentGrid.DataSource = Me.ExecuteQuery(cmd, "SELECT")' StudentGrid.DataBind()'Required for jQuery DataTables to work.' StudentGrid.UseAccessibleHeader = True' StudentGrid.HeaderRow.TableSection = TableRowSection.TableHeaderBindDummyRow()StudentGrid.DataBind()End IfEnd SubPrivate Sub BindDummyRow()Dim dummy As New DataTable()dummy.Columns.Add("Admno")dummy.Columns.Add("Name")dummy.Columns.Add("Class")dummy.Columns.Add("Stream")dummy.Columns.Add("SEX")dummy.Columns.Add("STDTYPE")dummy.Columns.Add("House")dummy.Columns.Add("ACNOS")dummy.Columns.Add("RClass")dummy.Rows.Add()StudentGrid.DataSource = dummyStudentGrid.DataBind()End SubPublic Shared Function GetCustomers(searchTerm As String, pageIndex As Integer) As StringDim query As String = "[GetCustomers_Pager2000]"Dim cmd As New SqlCommand(query)cmd.CommandType = CommandType.StoredProcedurecmd.Parameters.AddWithValue("@SearchTerm", searchTerm)cmd.Parameters.AddWithValue("@PageIndex", pageIndex)cmd.Parameters.AddWithValue("@PageSize", PageSize)cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.OutputReturn GetData(cmd, pageIndex).GetXml()End FunctionPrivate Shared Function GetData(cmd As SqlCommand, pageIndex As Integer) As DataSetDim strConnString As String = ConfigurationManager.ConnectionStrings("UNIFORMConnectionString").ConnectionStringUsing con As New SqlConnection(strConnString)Using sda As New SqlDataAdapter()cmd.Connection = consda.SelectCommand = cmdUsing ds As New DataSet()sda.Fill(ds, "Customers")Dim dt As New DataTable("Pager")dt.Columns.Add("PageIndex")dt.Columns.Add("PageSize")dt.Columns.Add("RecordCount")dt.Rows.Add()dt.Rows(0)("PageIndex") = pageIndexdt.Rows(0)("PageSize") = PageSizedt.Rows(0)("RecordCount") = cmd.Parameters("@RecordCount").Valueds.Tables.Add(dt)Return dsEnd UsingEnd UsingEnd UsingEnd FunctionProtected Sub OnCheckedChanged(sender As Object, e As EventArgs)Dim isUpdateVisible As Boolean = FalseDim chk As CheckBox = TryCast(sender, CheckBox)If chk.ID = "chkAll" ThenFor Each row As GridViewRow In StudentGrid.RowsIf row.RowType = DataControlRowType.DataRow Thenrow.Cells(0).Controls.OfType(Of CheckBox)().FirstOrDefault().Checked = chk.CheckedEnd IfNextEnd IfDim chkAll As CheckBox = TryCast(StudentGrid.HeaderRow.FindControl("chkAll"), CheckBox)chkAll.Checked = TrueFor Each row As GridViewRow In StudentGrid.RowsDim isChecked As Boolean = row.Cells(0).Controls.OfType(Of CheckBox)().FirstOrDefault().CheckedFor i As Integer = 1 To row.Cells.Count - 1' If row.Cells(i).Controls.Count > 0 Then'row.Cells(i).Controls.OfType(Of Label)().FirstOrDefault().Visible = Not isChecked' End IfIf row.Cells(i).Controls.OfType(Of TextBox)().ToList().Count > 0 Thenrow.Cells(i).Controls.OfType(Of TextBox)().FirstOrDefault().Visible = isCheckedEnd IfIf row.Cells(i).Controls.OfType(Of DropDownList)().ToList().Count > 0 Thenrow.Cells(i).Controls.OfType(Of DropDownList)().FirstOrDefault().Visible = isCheckedEnd IfIf isChecked AndAlso Not isUpdateVisible ThenisUpdateVisible = TrueEnd IfIf Not isChecked ThenchkAll.Checked = FalseEnd IfNextNextEnd Sub
m