Column Readonly cant function and how to update to database Using the ImportDataView method

I have using the import data view to load at the Grid and i want to make certain column to be readonly but i set the code but it cant work. And i using the import data view method how i update the data to the database.Note: ASP.net 2002,SQL server

Below is the code that i click the button then load the data to the grid

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click

Dim dataTable1 As DataTable

Dim oleDbConnection1 As System.Data.OleDb.OleDbConnection

Dim oleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter

Dim oleDbSelectCommand1 As System.Data.OleDb.OleDbCommand

oleDbConnection1 = New OleDbConnection()

oleDbDataAdapter1 = New OleDbDataAdapter()

oleDbSelectCommand1 = New OleDbCommand()

oleDbConnection1.ConnectionString = "Provider=sqloledb;User ID=sa ; pwd=123321; Data Source=ndtkomagsvr; Initial Catalog=spcdb"

oleDbSelectCommand1.Connection = oleDbConnection1

oleDbDataAdapter1.SelectCommand = oleDbSelectCommand1

dataTable1 = New DataTable()

dataTable1.Reset()

Try

oleDbSelectCommand1.CommandText = "SELECT (select t.Testtype_Name from SPC_Sputter_Testtype t where t.Testtype_Id = c.Testtype_Id)as Testtype_Name,(select ct.Charttype_Name from SPC_Sputter_Charttype ct where ct.Charttype_Id = c.Charttype_Id)as Charttype_Name,LSL,LCL,Target,UCL, USL, Rule1,Rule2, Rule3,Rule4,Offset,Intevac_Target_Prod FROM SPC_Sputter_ControlLimits_New c where Prod_type = '" & ddlProduct.SelectedItem.Value & "' and Sputter_Id = '" & ddlLine.SelectedItem.Value & "'"

oleDbDataAdapter1.Fill(dataTable1)

Finally

oleDbConnection1.Close()

End Try

' Clears datasheets first.

GridWeb1.WebWorksheets.Clear()

' Imports data from dataview object.

GridWeb1.WebWorksheets.ImportDataView(dataTable1.DefaultView, Nothing, Nothing)

GridWeb1.ShowHeaderBar = False

GridWeb1.WebWorksheets(0).Cells.SetColumnReadonly(0, True) ***cant work

GridWeb1.WebWorksheets(0).Cells.SetColumnReadonly(1, True) **** cant work

End Sub

*** first column and second column still can edit.

I no want the two column editable jsut only readonly

And how to uisng like that method to update the data to database

Hope someone can help me.

Thanks.

Hi,

Setting the column readonly only prevent the column from being deleted at the client side. You may use the WebCells.IsReadonly property of the WebWorksheet.SetReadonlyRange method to create readonly cell/cells.

To update dataset with the grid control, you may use the databind feature instead of the import feature. Please reference the online document:

Binding Worksheet

And you may check the online databinding demo:

Aspose.Grid Demos

Hi, About the Readonly, I have uisng below statement whether is correct or wrong?

GridWeb1.WebWorksheets(0).Cells.SetColumnReadonly(0, True)

GridWeb1.WebWorksheets(0).Cells.SetColumnReadonly(1, True)

GridWeb1.WebWorksheets(0).Cells.SetRowReadonly(0, True)

When i run the code the column and the row still can edit but i already set it as above code. I just want readonly for the hole column not specific range cell.

And for the update one i cant using other method example the databind one because i need to take the value from the drop down list then check with the database to take the specific data then bind to the grid. So if i using the example that show online i cant put value inside in It just can take one table and cant check any rule.

That one i try only suitable for one table. But for my case i need to take some value then only check with database then dispaly at Grid.

So about the update i no know how to use it ? is it same? i think not same .

Hope can help me again

thanks.

Hi,

As I have written in the last post, the SetColumnReadonly method can only prevent the column from being deleted at client side. So you have to use the SetReadonlyRange method to make that cells to be readonly.

With the databind feature, you may also use the Validation.LoadValueList method to load value/text pair into the list items from a dataview object. You may check the online demo, run the GridWeb FormView demo. In grid mode, you can see the "CategoryID" column. The dropdownlist displays the name of the category, but the selected value is the category's ID.

Hi,

I have try uisng the feature that state above but i try of it it still cant not reaonly

The Code that i added:

Dim sheet As WebWorksheet = GridWeb1.WebWorksheets(GridWeb1.ActiveSheetIndex)

sheet.SetAllCellsEditable()

sheet.SetReadonlyRange(3, 2, 4, 1)

AND for the Databind i think u miss understand my meaning already

i no want bind the dropdownlist at the gridweb i means get value from dropdownlist then call to bind to the grid.

I means that B4 the Gridweb bind with data i need to choose two value from two different dropdownlist From the 2 value i need to check with database only the data related with this two value then the information only bind to the grid. (Means at the SQL statement the two value will be at WHERE statement) but the example show is direct using the control then all database that want to use already add to database. Can it be like what i mean above then using the control?

I really no know how to using Whoksheets Designer with calling the value from the dropdownlist.