Community discussion forum

asp.net determine datagrid for binding programmatically

  • 5 months 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 was edited on 18/06/2009 13:45:01 Report abuse

Post a reply

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

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

Want to stay in touch with what's going on? Follow us on twitter!