asp.net determine datagrid for binding programmatically

asp.net , datagrid , code , binding United States
  • 11 years ago

    Have multiple datagrids on same page in tab panel. I want to set up one sub to do the databinding for all datagrids. Having trouble with the code to actually identif which datagrid. Each datagrid is identified by the index of the tab panel, e.g. dg0, dg1, dg2, dg3, etc. How do I tell it in code which datagrid to use? Doesn't like what I've been trying. Many thanks.

    Sub getView(ByVal style As String, ByVal panel As Integer)
    Dim 
    myDatagrid As String = "dg" & panel.ToString
    ....do query and get datasource stuff
    Dim myView as data.dataView= ds.Tables(panel).DefaultView
    Dim mystring As String = "dg" & panel.ToString
    CType(myDatagrid, DataGrid).DataSource = myView
    Ctype(myDatagrid, DataGrid).DataBind()
    

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The trouble with programmers is that you can never tell what a programmer is doing until it's too late.” - Seymour Cray