I'm getting frustrated with the Gridview control. I'm populating the Gridview like this...
VB Code:
dt = obj.getDataTable("SELECT * FROM tblsamplestrings") gvTranslations.DataSource = dt gvTranslations.DataBind()
I'm using "SELECT *" because tblsamplestrings will be variable and each table has different fields. So everything renders as expected. Now when the user clicks "Update" I need to know the column names so that I can construct an UPDATE statement. But I can't figure out how to get the column names and the column count property is ZERO (I'm guessing because the columns were autogenerated). So this is where I am stuck...
VB Code:
Protected Sub gvTranslations_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles gvTranslations.RowUpdating Dim row As GridViewRow = gvTranslations.Rows(e.RowIndex) Dim columnCount As Integer = gvTranslations.Columns.Count End Sub
Any help would be much appreciated.
UDPATE: I managed to get the column names using a workaround. So now I'm stuck on the UPDATE statement.
I have this code...
VB Code:
Protected Sub gvTranslations_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles gvTranslations.RowUpdating Dim y As Integer = 0 Dim row As GridViewRow = gvTranslations.Rows(e.RowIndex) Dim obj As New ERSLib.Data.PublicFunc Dim sb As New StringBuilder sb.Append("UPDATE tblSampleStrings SET TYPE_ = '" & needNewValueHere & "'") obj.runSql(sb.ToString) obj.close() obj = Nothing End Sub
How do I fill the needNewValueHere variable with the appropriate value? I've tried everything I can think of. e.newvalues is empty. row.cells(e.rowindex) is empty. This is so frustrating![]()




Reply With Quote