Dynamically created datagrid and i8n ?


L

lothar.behrens

Hi,

I have created a DataGrid, whose columns are created automatically
based on a SQL query.
Using the following function does not do it's work as expected:

Private Sub Grid_ItemDataBound(ByVal sender As Object, ByVal e
As _
System.Web.UI.WebControls.DataGridItemEventArgs)
Handles _
Grid.ItemDataBound
If (e.Item.ItemType = ListItemType.Header) Then
For counter As Integer = 0 To e.Item.Cells.Count - 1
e.Item.Cells(counter).Text =
Translate(e.Item.Cells(counter).Text)
Next counter
End If
End Sub

The columns seems to be not yet created and I'll get empty headers
instead the untranslated columns. If Translate didn't find a
translation (resx file), it returns the given value.

Any Ideas, why I get empty headers ?

Thanks, Lothar

I do setup the grid like this:

Protected Sub refreshGrid()
Dim myconnection As New SqlConnection(conStr)
myconnection.Open()
Dim oCommand As SqlDataAdapter
oCommand = New SqlDataAdapter(Session("SQLQuery"),
myconnection)
Dim MyDataSet As New DataSet

Try
oCommand.Fill(MyDataSet, "SQLQuery")
gridBalance.DataSource = MyDataSet
gridBalance.AllowPaging = True
gridBalance.AllowSorting = True
gridBalance.DataKeyField = "I_MyKeyField"
gridBalance.DataBind()
Catch ex As Exception
ErrorMsg("Error: Could not show data in grid!")
End Try
End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top