IT Community - Software Programming, Web Development and Technical Support

selecting check box in Gridview and displaying content for that checked check box

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)...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 11-22-2008, 10:31 AM
hardikvaghela19 hardikvaghela19 is offline
D-Web Trainee
 
Join Date: Nov 2008
Posts: 1
hardikvaghela19 is on a distinguished road
Default selecting check box in Gridview and displaying content for that checked check box

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>
&nbsp;</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>
&nbsp;</td>
</tr>
<tr>
<td>
<asp:Button ID="btnproceed" runat="server" onclick="btnproceed_Click"
Text="Proceed" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;
<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">
&nbsp;</td>
</tr>
</table>
</asp:Content>


WHAT WILL BE THE CODE BEHIND THIS FORM TO SHOW RELATED VALUES MATCHED WITH "NAME"
Attached Images
File Type: jpg software sublevel form.JPG (115.4 KB, 2 views)
File Type: jpg software_threats_form.JPG (124.2 KB, 1 views)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Doubt with check-in and options check-out arjkhanna Server Management 5 07-19-2009 07:37 PM
check points simplesabita Testing Tools 1 08-22-2007 03:10 AM
How may Check points available in QTP with Example? sundarraja Testing Tools 1 08-14-2007 04:10 AM
Web content check tripnautic HTML, CSS and Javascript Coding Techniques 2 05-01-2007 05:56 AM
Site content check tripnautic Search Engine Optimization 1 03-28-2007 06:04 AM


All times are GMT -7. The time now is 07:32 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0