Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi Guys / Girls,

 

I've got a deadline tommorrow and I"m stuck.

 

I've got a datagrid wired up perfectly to a datatable. However, I need an extra column for calculations. I can't seem to add it. If I add it on the resport.aspx page then it shows but I can't add data. But if I try and add the column to the datatable (see below) at runtime then it doesn't show. What am I doing wrong. Please can someone show me how to add a column to a datatable at runtime and have it show up? Thx. I"ll owe you one.

 

 

 

----------------------------------------------

report.aspx:

 

 

<ASP:Datagrid AutoGenerateColumns="false" OnItemDataBound="CalcTotal" ShowFooter="True" id="grdQueryResults" runat="server" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" width="200">

 

<Columns>

 

<ASP:BoundColumn DataFormatString="{0:d}" HeaderText="Start Date" DataField="datStartDate"></ASP:BoundColumn>

 

<ASP:BoundColumn DataFormatString="{0:d}" HeaderText="End Date" DataField="datEndDate"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Number of Contacts Registered in CIMA" DataField="intInterestTotal"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Application Completed" DataField="intAppCompleted"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Cancelled" DataField="intAppCancelled"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Ready For Review" DataField="intAppReadyForReview"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Review Completed" DataField="intAppReviewComplete"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Held" DataField="intAppHeld"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Deferred" DataField="intDeferred"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Rejected" DataField="intRejected"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Offer Sent" DataField="intOfferSent"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Offer Declined" DataField="intOfferDeclined"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Wait List" DataField="intWaitlist"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Offer Accepted" DataField="intOfferAccepted"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Conditional Acceptance" DataField="intConditionalAcceptance"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Total Applicants" DataField="intTotalApplicants"></ASP:BoundColumn>

 

<ASP:BoundColumn HeaderText="Learners Enrolled" DataField="intLearnersEnrolled"></ASP:BoundColumn>

 

</Columns>

</ASP:Datagrid>

 

-------------------------------------------------------

 

report.aspx.vb

 

'create datatable

Dim dt As New DataTable()

Dim da As New SqlDataAdapter()

da.SelectCommand = cmd

da.Fill(dt)

 

'create datacolumn

Dim dcPercentage1 As New DataColumn("Percentage of Applicants from Contacts", GetType(Integer))

dcPercentage1.Expression = "((12 / 6) * 100)"

dt.Columns.Add("dcPercentage1", GetType(Integer))

 

 

' Associate the data grid with the data

Me.grdQueryResults.DataSource = dt

Me.grdQueryResults.DataBind()

cnn.Close()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...