This is a discussion on selecting check box in Gridview and displaying content for that checked check box within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi, I am a beginner with asp.net. need help for the below functionality. my project has two forms 1)...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, I am a beginner with asp.net. need help for the below functionality. my project has two forms 1)Software sublevels 2)software threats 1)Software sublevel associated with following table name: Software_sublevel column sec_sublevel_id (PK,varchar(max)) sec_sublevel_name (varchar(max)) 2) software threats form associated with following table: table name: Software_threats column sec_sublevel_id (FK,varchar(max)) threat_id (PK,varchar(max)) threat_name (varchar(max)) threat_desc(varchar(max)) tool_name(varchar(max)) tool_desc(varchar(max)) SOFTWARESUBLEVEL form has grid view which shows checkbox | Name [] | policy [submitbutton] I want to implementing a functionality that if the checkbox is checked on this form and if i click a submit button it takes the selected name and shows the values related to name in the software threats form. Software sublevel[form:1] form's asp content <%@ Page Language="C#" MasterPageFile="~/WebUI/Afterlogin.Master" AutoEventWireup="true" CodeBehind="Softwaresublevel.aspx.cs" Inherits="Security_Tools.WebUI.Softwaresublevel" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <table style="width: 100%"> <tr> <td> <b>Please Select Sub Level</b></td> </tr> <tr> <td> </td> </tr> <tr> <td> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" PageSize="5"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:BoundField DataField="sec_sublevel_name" HeaderText="Software SubLevel" SortExpression="sec_sublevel_name" /> <asp:TemplateField HeaderText="Applicable"> <ItemTemplate> <asp:CheckBox ID="CheckBoxchecked" runat="server" Enabled="true" /> </ItemTemplate> </asp:TemplateField> </Columns> <PagerStyle BackColor="#284775" BorderStyle="Solid" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:295ConnectionString %>" SelectCommand="SELECT [sec_sublevel_name] FROM [Software_sublevel]"> </asp:SqlDataSource> </td> </tr> <tr> <td> </td> </tr> <tr> <td> <asp:Button ID="btnproceed" runat="server" onclick="btnproceed_Click" Text="Proceed" />   ; <asp:Button ID="btncancel" runat="server" Text="Cancel" Width="72px" /> </td> </tr> </table> </asp:Content> CODE BEHIND this form: using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Xml.Linq; using System.Text; using System.Collections.Generic; namespace Security_Tools.WebUI { public partial class Softwaresublevel : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnproceed_Click(object sender, EventArgs e) { List<string> subLevelName = new List<string>(); for (int i = 0; i < GridView1.Rows.Count; i++) { //int subLevelId = (int)GridView1.DataKeys[i][0]; GridViewRow row = GridView1.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("CheckBoxchecked")).Che cked; if (isChecked) { //subLevelList.Add(subLevelId); subLevelName.Add(GridView1.Rows[i].Cells[1].Text); } } SoftwareSublevel ss = new SoftwareSublevel(); ss.selectedCheckBox(subLevelName); Response.Redirect("SoftwareThreats.aspx"); } } } IN THE NEXT SOFTWARE THREATS FORMS I WANT TO SHOW INFORMATION FROM THE SOFTWARE THREATS TABLE MATCHING WITH "NAME" COLUMN THAT I AM PASSING THROUGH ABOVE FORM. ASP CODE FORM FOR SOFTWARETHREAT.ASPX <%@ Page Language="C#" MasterPageFile="~/WebUI/Afterlogin.Master" AutoEventWireup="true" CodeBehind="SoftwareThreats.aspx.cs" Inherits="Security_Tools.WebUI.SoftwareSublevel" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <table style="width: 111%"> <tr> <td style="width: 8px; height: 467px;"> Software Sub Level</td> <td style="height: 467px"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" BorderStyle="Groove" CellPadding="4" ForeColor="#333333" GridLines="None" Height="425px" PageSize="5" style="text-align: left" Width="517px"> <PagerSettings Mode="NextPreviousFirstLast" /> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:BoundField DataField="threat_name" HeaderText="Question" SortExpression="threat_name" /> <asp:BoundField DataField="threat_desc" HeaderText="Description" SortExpression="threat_desc" /> <asp:BoundField DataField="tool_name" HeaderText="SuggestedTool" SortExpression="tool_name" /> <asp:BoundField DataField="tool_url" HeaderText="ToolInfo" SortExpression="tool_url" /> <asp:BoundField DataField="tool_cost" HeaderText="Cost" SortExpression="tool_cost" /> <asp:TemplateField HeaderText="Apply"> <ItemTemplate> <asp:CheckBox ID="CheckBoxchecked" runat="server" Enabled="true" /> </ItemTemplate> </asp:TemplateField> </Columns> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:295ConnectionString %>" SelectCommand="SELECT [threat_name], [threat_desc], [tool_name], [tool_url], [tool_cost] FROM [Software_threats]"> </asp:SqlDataSource> </td> </tr> <tr> <td style="width: 8px; height: 6px;"> </td> <td style="height: 6px"> </td> </tr> </table> </asp:Content> WHAT WILL BE THE CODE BEHIND THIS FORM TO SHOW RELATED VALUES MATCHED WITH "NAME" |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where can I check SEO scores??? | rosy0123 | Search Engines | 5 | 01-01-2009 12:22 AM |
| TFS check-in problem | arjkhanna | ASP and ASP.NET Programming | 9 | 08-16-2007 10:06 AM |
| Web content check | tripnautic | HTML, CSS and Javascript Coding Techniques | 2 | 05-01-2007 06:56 AM |
| How to check the URL testing? | vadivelanvaidyanathan | Software Testing | 2 | 04-13-2007 04:58 AM |
| Site content check | tripnautic | Search Engine Optimization | 1 | 03-28-2007 07:04 AM |