.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 17th, 2012, 09:11 PM
new2net1 new2net1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 1 new2net1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 4 sec
Reputation Power: 0
Smile Checkbox, DropDownlist and Button in Gridview

Hi,


I am new to Dot Net and I am basic knowledge of Grid view. I am trying to get some intermediate grid view knowledge. So please share and help me to get some knowledge.

I am trying to know Check box,dropdownlist and button are generated for each row in Grid view.I am using C# language.
If I checked the check box and button was clicked some action will happen, in between i true the property Autopostback of check box true, When check box is clicked the drop down list in the row should update the correct data for the row and if the button is clicked, the specific action is triggered, the selected row will display at the bottom of the page in nested grid view or separate grid view.

Please share you thoughts. For your convenience I have attached my 50% of code with this query.. I hope I will get the answer soon.

Aspx Code
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ltest.aspx.cs" Inherits="ltest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
        CellPadding="4" ForeColor="Black" GridLines="Horizontal" Height="241px"
        Width="374px">
            <Columns>
                <asp:TemplateField HeaderText="Select">
                    <ItemTemplate>
                <asp:CheckBox ID="gcb" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                                <asp:TemplateField HeaderText="ID">
                    <ItemTemplate>
                        <%#Eval("id")  %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <%#Eval("name")  %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="designation">
                    <ItemTemplate>
                        <asp:DropDownList ID="dd_desghnation" runat="server">
                            <asp:ListItem> --Select--</asp:ListItem>
                         
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Details">
                    <ItemTemplate>
                <asp:Button ID="gb" runat="server" Text="Show"/>
                    </ItemTemplate>
                </asp:TemplateField>
                
            </Columns>
            <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
            <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        </asp:GridView>
    </div>
    </form>
</body>
</html>


Cs code

Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.Data.SqlClient;

public partial class ltest : System.Web.UI.Page
{
    DropDownList bind_dropdownlist;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            gv();

        }

    }
    public void gv()
    {

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ltest"].ToString());
        con.Open();
        string str = "select * from ltest";
        SqlCommand cmd = new SqlCommand(str,con);
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);

        if (dt.Rows.Count > 0)
        {
            GridView1.DataSource = dt;
            GridView1.DataBind();
            foreach (GridViewRow grdRow in GridView1.Rows)
            {
                bind_dropdownlist = (DropDownList)(GridView1.Rows[grdRow.RowIndex].Cells[2].FindControl("dd_desghnation"));
                bind_dropdownlist.DataSource = dt;
                bind_dropdownlist.DataValueField = "ID";
                bind_dropdownlist.DataTextField = "detination";
                bind_dropdownlist.DataBind();
            }

        }


    }
    }

Reply With Quote
  #2  
Old May 2nd, 2012, 05:47 AM
robertalis robertalis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 7 robertalis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 59 m 43 sec
Reputation Power: 0
Hello
all the requirements as you mentioned, I think dapfor .net grid can solve your problem- just check the .net grid features here
www. dapfor.com/en/net-suite/net-grid/features

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Checkbox, DropDownlist and Button in Gridview

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap