Datagrid, BoundColumns, and Checkboxes

Results 1 to 2 of 2

Thread: Datagrid, BoundColumns, and Checkboxes

  1. #1
    Join Date
    Dec 1969

    Default Datagrid, BoundColumns, and Checkboxes

    I&#039;m writing a web app that will display a datagrid of services offered with checkboxes to allow theuser to select to buy that service. The other columns are all bound to a stored procedure I&#039;ve written. My problem is that I can&#039;t figure out how to retrieve the information stored in the bound columns when I&#039;m checking to see which check boxes were selected. I can however create an asp label template column like so:<BR><BR>&#060;asp:TemplateColumn SortExpression="demo" HeaderText="Column"&#062;<BR>&#060;ItemTemplate&#0 62;<BR>&#060;asp:Label ID="lblColumn" runat="server" Visible="False" Text=&#039;&#060;%# DataBinder.Eval(Container.DataItem, "Product_Code") %&#062;&#039; Width="80%"/&#062;<BR>&#060;/ItemTemplate&#062;<BR>&#060;/asp:TemplateColumn&#062;<BR><BR>I can retrieve the data from this label webcontrol perfectly fine using this method:<BR><BR>For Each oDataGridItem In DG_Features.Items<BR>chkFeatureSel = oDataGridItem.FindControl("FeatureSel")<BR> If chkFeatureSel.Checked Then<BR> sID = CType(oDataGridItem.FindControl("lblColumn"), Label).Text<BR> oExArgs.Add(sID)<BR><BR> Msg.Text = Msg.Text + " Test " + sID<BR> End If<BR>Next<BR><BR>Is there anyway I can do a similar approach and just pull the data straight from the bound column? Thanks<BR><BR>Ben Cook

  2. #2
    Join Date
    Dec 1969

    Default RE: Datagrid, BoundColumns, and Checkboxes

    If you have a bound column that has the product code, you can grab the text of that column (even if it&#039;s hidden). Assuming that the Product_Code is in the first column (hence index 0 below), do this:<BR><BR>sID = oDataGridItem.Cells(0).Text<BR><BR>Otherwise, the way you did it is perfectly fine. You can hide that column if you don&#039;t want it displayed and still retrieve its value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts