473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Creating Checkbox Dynamically in Data Grid using VB.NET Web Form

Hi,

I am trying to create a web page whereby I first read data from Oracle Database and display the records out on the data grid. The data displayed is in order of one attribute say 'A' meaning that some records have the same value for 'A'. I need to display only 1 checkbox per group of records which has the same attribute 'A'. When the checkbox is checked, I need to update the database for all of the records with the same attribute 'A'.

Does anyone knows how this can be done? I have managed to display the checkbox for beside all the records using the following code in the .aspx file but is clueless on how to make it such that i will have 1 checkbox per group of records.


<TD><asp:datagrid id="DataGrid1" runat="server" ForeColor="Black" Font-Size="XX-Small" Font-Names="Verdana"
AutoGenerateColumns="False" Width="100%" Height="100%" HorizontalAlign="Left" AllowSorting="True"
BackColor="#C0C0FF">
<AlternatingItemStyle HorizontalAlign="Left" BorderStyle="Solid" Width="100%" VerticalAlign="Middle" BackColor="#FFE0C0"></AlternatingItemStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Verdana" HorizontalAlign="Left" ForeColor="Black"
Width="100%" VerticalAlign="Middle" BackColor="#C0C0FF"></ItemStyle>
<HeaderStyle Font-Size="XX-Small" Font-Names="Verdana" Font-Bold="True" HorizontalAlign="Center"
ForeColor="White" Width="100%" VerticalAlign="Middle" BackColor="DarkSlateBlue"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="ProductName">
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server" AutoPostBack="True"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="EVENT_ID" HeaderText="Event ID"></asp:BoundColumn>
<asp:BoundColumn DataField="DEPO_ID" HeaderText="Depository ID"></asp:BoundColumn>
<asp:BoundColumn DataField="SEC_ID" HeaderText="GEMS Security ID"></asp:BoundColumn>
<asp:BoundColumn DataField="SEC_SHORT_DESC" HeaderText="Security Description"></asp:BoundColumn>
<asp:BoundColumn DataField="LIST_CNTRY" HeaderText="Country"></asp:BoundColumn>
<asp:BoundColumn DataField="EX_DATE" HeaderText="Ex-Date"></asp:BoundColumn>
<asp:BoundColumn DataField="EFFECTIVE_DATE" HeaderText="Effective Date"></asp:BoundColumn>
<asp:BoundColumn DataField="CA_TYPE" HeaderText="CA Type"></asp:BoundColumn>
<asp:BoundColumn DataField="M_V_INDICATOR" HeaderText="Indicator"></asp:BoundColumn>
<asp:BoundColumn DataField="STATUS" HeaderText="Status"></asp:BoundColumn>
<asp:BoundColumn DataField="CREATED_BY" HeaderText="Created By"></asp:BoundColumn>
<asp:BoundColumn DataField="CREATED_DT_TM" HeaderText="Created Date Time"></asp:BoundColumn>
<asp:BoundColumn DataField="LAST_MOD_BY" HeaderText="Last Modified By"></asp:BoundColumn>
<asp:BoundColumn DataField="LAST_MOD_DT_TM" HeaderText="Last Modified Date Time"></asp:BoundColumn>
<asp:BoundColumn DataField="CA_FILE_STATUS" HeaderText="CA File Status"></asp:BoundColumn>
<asp:BoundColumn DataField="REMARKS" HeaderText="Remarks"></asp:BoundColumn>
</Columns>
</asp:datagrid></TD>


Thanks!
Mar 29 '08 #1
2 2666
balabaster
797 Expert 512MB
I think you may be going about this slightly incorrectly. You've gone through the process of grabbing the database and using it as a data source for your grid, which is standard practice and for usual everyday tasks, this would be correct.

However, in this case, what I think you'll need to do is parse the dataset that you grabbed from the database and iterate through it row by row and build your grid. When the current record holds a new attribute, add a row that contains your checkbox above the one you're currently working on, add a hidden field that contains a list of the keys that will be dynamically built from id's for the current group. As you parse a new record, you check to see if the group is still the same one, if it is, add it to the contents of the hidden field. If it's not the same, create a new row with a new checkbox and a new hidden field to repeat the process over.

There might be a bit more of a slick way to do this, but I think this is the bare bones of the technique that will get you started.
Mar 30 '08 #2
Hi,

Thanks very much for your suggestion! Think this is what I need !!.. but I am still not sure how to parse the dataset and iterate to compare the values. I was searching for some suggestion online but could not find any. Do you know how to iterate the data set through each row of results and comparing the first cell of each row with the other rows to see if they are the same? Lastly, how to I add a check box or other template columns to each row of datagrid as I am building it?




I think you may be going about this slightly incorrectly. You've gone through the process of grabbing the database and using it as a data source for your grid, which is standard practice and for usual everyday tasks, this would be correct.

However, in this case, what I think you'll need to do is parse the dataset that you grabbed from the database and iterate through it row by row and build your grid. When the current record holds a new attribute, add a row that contains your checkbox above the one you're currently working on, add a hidden field that contains a list of the keys that will be dynamically built from id's for the current group. As you parse a new record, you check to see if the group is still the same one, if it is, add it to the contents of the hidden field. If it's not the same, create a new row with a new checkbox and a new hidden field to repeat the process over.

There might be a bit more of a slick way to do this, but I think this is the bare bones of the technique that will get you started.
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: James | last post by:
I am creating a system whereby equipment is inspected. Data is inputted into an inspection form. However, any equipment that is not satisfactory needs to have spare parts ordered for that piece of...
2
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
1
by: Paul | last post by:
HI I have a asp page which dynamically creates a table with 28 rows, 3 columns. Column 1 contains a label, column 2 contains a graphic, column 3 needs to contain a checkbox. I have no problems...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
7
by: RHPT | last post by:
I have a checkbox that I dynamically check (via JavaScript) when the user initiates an action on the page. I want to prevent the user from unchecking the box if that action has been initiated and...
5
by: SalamElias | last post by:
I am creating several chkBoxes dynamically and assigning an event handler in the Page_load as foillows ***************************** Dim chkCatOption As CheckBox = New CheckBox chkCatOption.Text...
2
by: somaskarthic | last post by:
Hi In my php code , i dynamically created table rows on button click event. Each row contain 3 selectboxes, 7 checkboxes . On each click of these elements i need to submit the form and save the...
1
by: Josh | last post by:
Using Visual Studio 2003, C#, .NET 1.1. I have a web form with a few textboxes, a couple of dropdown lists, and a data grid. The data grid is populated from a SQL stored procedure. The user...
0
by: lianaent | last post by:
Hi All, I'm brand new to asp.net 2.0, and have a simple task of just creating a quick and dirty data entry form with SQL Server 2005 on the back end. I added a gridview to my form, and I can...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.