Populating a Table not a datagrid

  • Thread starter Thread starter coleenholley
  • Start date Start date
C

coleenholley

Hi All :-)

I need to populate a table I created as a web form. Are there any links to show me how to do this? I CANNOT use a dtagrid for this, the table has to be laid out as follows:

Header Row Header Row
Static data Dynamic (read only) data

<Break>

Header Row Header Row Header Row Header Row
Static Data Dynamic (read only) Dynamic (read only) Calcultiion


This makes it impossible for me to use a datagrid - Unless someone has a link to how to do this in a datagrid - I MUST be able to have one column of static data, two columns of dynamic read only data, and a total column to display the calculation in...I also need a footer to display calculations in the TOTALS Row at the bottom of the page... I have not been able to find any VB samples on how to do this with a datagrid, and am hoping some one has a link to show me how to do this with a ASP.Net Table...any suggestions? TIA - Coleen
 
Sure, this can be done with datagrids. However, you'll need two of them
(looks like you have 2 tables here).
Use a BoundColumn for the dynamic data, and a non-bound column for the
static data.
The alternative is to forget the datagrid entirely, and create the HTML
table yourself by running a bunch of Repsponse.Write() statements that set
up the <TABLE><TR>and <TD> elements manually.

-Rob Teixeira [MVP]

Hi All :-)

I need to populate a table I created as a web form. Are there any links
to show me how to do this? I CANNOT use a dtagrid for this, the table has
to be laid out as follows:
Header Row Header Row
Static data Dynamic (read only) data

<Break>

Header Row Header Row Header Row Header Row
Static Data Dynamic (read only) Dynamic (read only) Calcultiion


This makes it impossible for me to use a datagrid - Unless someone has a
link to how to do this in a datagrid - I MUST be able to have one column of
static data, two columns of dynamic read only data, and a total column to
display the calculation in...I also need a footer to display calculations in
the TOTALS Row at the bottom of the page... I have not been able to find any
VB samples on how to do this with a datagrid, and am hoping some one has a
link to show me how to do this with a ASP.Net Table...any suggestions?
TIA - ColeenCommunity Website: http://www.dotnetjunkies.com/newsgroups/
 
Yes I can do this with two datagrids, but as I stated before, every sample that I have found is listed in C, Not in VB do you have any suggestions where I can find samples in VB to do this? Part of my problem is the type of connection we use...we do not connect to an SQL database, we use DB2 through RPC's written in COBOL. This makes everything more difficult, and trying to make sense of samples written in C is not helping...any suggestions? Thanks for your response :-)
 
Hm, that's odd. Most samples (at least on the Microsoft site) have both C#
and VB examples.
However, you can do most of the work without actually coding - in other
words, playing with the property builders and designers of the datagrid
control itself. So that should take some of the burden off, hopefully.

As for the DB2/COBOL thing - some of the RPC bridges I've seen use drivers
that emulate an ODBC layer. One that I've worked with recently is NEON, and
while the call itself looks nothing like SQL, the return values are
populated in rows and columns conforming to an ODBC result set. If your RPC
mechanism works like that, then you can usually substitute the SQL ADO.NET
provider classes with the ODBC ADO.NET provider classes. So basically,
instead of a SQLConnection, you'll have an ODBCConnection, and so on. The
important thing is that at some point, regardless of which provider you use,
you'll end up with a DataSet, which represents the return values, and the
code should be all the same from there on out.

-Rob Teixeira [MVP]

Yes I can do this with two datagrids, but as I stated before, every sample
that I have found is listed in C, Not in VB do you have any suggestions
where I can find samples in VB to do this? Part of my problem is the type
of connection we use...we do not connect to an SQL database, we use DB2
through RPC's written in COBOL. This makes everything more difficult, and
trying to make sense of samples written in C is not helping...any
suggestions? Thanks for your response :-)Community Website: http://www.dotnetjunkies.com/newsgroups/
 
We've actually been able to write a class module to do the connection for us, but we run into wierd problems with Paging and PostBack. I use the If Not Page.IsPostBack Then...statement alot, and it works most of the time. I'm still having trouble getting the samples I've found for custom paging to work correctly for me. I get the numeric <> pages but when I click them, the next page to come up is blank (no datagrid, no labels, nothing?) so I'm working on that along with creating a page with two datagrids with Static data in one column. I know I can use a bound column for this, but what I'm confused on is how to populate the static data- the data in this column will be different for each row; i.e., static column row 1 = Carson City, row 2 = Churchill, row 3 = Clark...each row will have corresponding data in other columns that is dynamic and read-only, that part I understand. Is there a way to actually write the static data into the column? Like in an HTML table I can actually populate the column with exactly the text I want, how do I do that with a datagrid? I appreciate any/all help :-) Thank you
 
After you bind, you can go through the datagrid's Items and Cells
collections to change text, etc. Another alternative is to use template
columns, but that's more cumbersome (at least in my opinion).
Part of your problem with blank grids is the fact that default paging
requires you to refetch the entire set of data. I suspect that your checks
for PostBack are stopping this from happening. You will definitely want to
work with custom paging if you'd rather not get all the data for each page
every time you click to a different page. Remember that the datagrid doesn't
remember ALL the data bound to it, just the rows that appear on the current
page.

-Rob Teixeira [MVP]

We've actually been able to write a class module to do the connection for
us, but we run into wierd problems with Paging and PostBack. I use the If
Not Page.IsPostBack Then...statement alot, and it works most of the time.
I'm still having trouble getting the samples I've found for custom paging to
work correctly for me. I get the numeric <> pages but when I click them,
the next page to come up is blank (no datagrid, no labels, nothing?) so I'm
working on that along with creating a page with two datagrids with Static
data in one column. I know I can use a bound column for this, but what I'm
confused on is how to populate the static data- the data in this column will
be different for each row; i.e., static column row 1 = Carson City, row 2 =
Churchill, row 3 = Clark...each row will have corresponding data in other
columns that is dynamic and read-only, that part I understand. Is there a
way to actually write the static data into the column? Like in an HTML
table I can actually populate the column with exactly the text I want, how
do I do that with a datagrid? I appreciate any/all help :-) Thank you!Community Website: http://www.dotnetjunkies.com/newsgroups/
 
I know this is a lot of code, but here is what I have;

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
uf_get_supplier_list()
End If
End Sub

Private Sub uf_get_supplier_list()
'This function gets the Withdrawal listing if available.
'Define the local variables.
Dim li_no_row As Integer = 0

Try
'Instantiate an RPC to get an Withdrawal Listing.
lo_AZRM001A_SEL = New MotorFuel.AZRM001A_SEL()
lo_misc_func = New MotorFuel.misc_func()
Catch
'Destroy the objects.
lo_AZRM001A_SEL = Nothing
lo_misc_func = Nothing
End Try

'Check for CICS call.
If lo_AZRM001A_SEL.uf_cicscall() Then
'If CICS call is true then move forward.
'Check for the dci error code.
If lo_AZRM001A_SEL.get_dci_error_code = "0000" Then
'Convert the string value to the interget value.
If lo_misc_func.IsNumeric(lo_AZRM001A_SEL.get_dci_row_count) = True Then
li_no_row = Integer.Parse(lo_AZRM001A_SEL.get_dci_row_count)
Else
li_no_row = 0
End If

'Set the data to the Data Grid if the li_no_row is not equal "0".
If li_no_row <> 0 Then
If Page.IsPostBack = False Then
'dtg_sel_sup.DataSource = lo_AZRM001A_SEL.get_ddl_sel_sup
dt_mc = lo_AZRM001A_SEL.get_ddl_sel_sup
dtg_load_data()
End If
Else
End If

'Destroy the objects.
lo_AZRM001A_SEL = Nothing
lo_misc_func = Nothing
End If
Else
'Destroy the objects.
lo_AZRM001A_SEL = Nothing
lo_misc_func = Nothing

End If

End Sub


Private Sub btn_sel_sup_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_sel_sup_ok.Click
Response.Redirect("../Common/mc_rpt_period.aspx")
End Sub

Sub dtg_load_data()
dtg_sel_sup.DataSource = dt_mc
dtg_sel_sup.DataKeyField = "BusinessID"
dtg_sel_sup.DataMember = "BusinessName"
dtg_sel_sup.DataMember = "Account"
dtg_sel_sup.DataBind()

'Destroy the objects.
lo_AZRM001A_SEL = Nothing
lo_misc_func = Nothing
End Sub

Sub dtg_sel_sup_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)

dtg_sel_sup.CurrentPageIndex = e.NewPageIndex

End Sub

I'm not sure if it is the lack of a Not page.isPostBack that is causing me the problem in my dataload sub or not...any suggestions? Thanks very much for your help :-)
 
Back
Top