Showing posts with label Gird View Example. Show all posts
Showing posts with label Gird View Example. Show all posts

Update Record in Gridview with Naming Container in Asp.net using c#

Posted by Unknown On Tuesday, 19 March 2013 0 comments
First desing the page like following way


<table border="2">
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="Product Name"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Product Name Required" Text="*" ControlToValidate="TextBox1" ValidationGroup="val1"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Enter valid product name" ControlToValidate="TextBox1" ValidationExpression="[a-zA-Z ]+" ValidationGroup="val1"></asp:RegularExpressionValidator>
            </td>
READ MORE

Delete in Gridview With DropdownListBox

Posted by Unknown On 0 comments
First Design The page take one Gridview.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>
                    <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True"
                        oncheckedchanged="CheckBox2_CheckedChanged" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Id">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("id") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
READ MORE

Delete in Gridview with CheckBox in Asp.net Using C#

Posted by Unknown On 5 comments
First Design The Page like following way take one Gridview and One Button for Delete

The Following is .aspx page design


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>
                    <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True"
                        oncheckedchanged="CheckBox2_CheckedChanged" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Id">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("id") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
READ MORE

Nested GridView in ASp.net C#

Posted by Unknown On Friday, 15 March 2013 1 comments
Following is the .aspx file code write this first. . .
<script type="text/javascript">
        function showNestedGridView(obj) {
            var nestedGridView = document.getElementById(obj);
            var imageID = document.getElementById('image' + obj);

            if (nestedGridView.style.display == "none") {
                nestedGridView.style.display = "inline";
                imageID.src = "minus.png";
            } else {
                nestedGridView.style.display = "none";
                imageID.src = "plus.png";
            }
        }
</script>
<br />
<br />
<br />
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
        DataKeyNames="pid" ShowFooter="True"
        onrowdatabound="GridView1_RowDataBound"
        onrowcommand="GridView1_RowCommand">
        <Columns>

READ MORE

Display database data in Gridview in asp.net with c#

Posted by Unknown On Friday, 8 March 2013 0 comments

First of all you have to create sql connection with the database...
            For this see the following link


now use the following code for gridview bind in button click event...

protected void Button1_Click(object sender, EventArgs e)
    {
               con.open();
               SqlDataAdapter adp=new SqlDataAdapter("Select * from Emp",con);
               DataTable dt=new DataTable();
               adp.Fill(dt);
                GridView1.DataSource=dt;
                 GridView1.Databind();
    }

READ MORE