Hi
how to Show only One Save button at center of last button Column when Customer are duplicate.
and button must me at middle if it has rowspan
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="A_Gridview_Example1.aspx.cs"
Inherits="A_Gridview_Example1" EnableEventValidation="false" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="10" Visible="true">
<ProgressTemplate>
<span>Loading Please Wait...</span>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<div>
<table>
<tr>
<td align="left" valign="top">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CssClass="Gridview"
DataKeyNames="Prod_ID" ShowFooter="true" OnRowDataBound="GridView1_RowDataBound"
CellPadding="4" AllowPaging="false" AllowSorting="false">
<HeaderStyle BackColor="#9CAAC1" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
<PagerStyle BackColor="#9CAAC1" Font-Bold="True" ForeColor="Black" HorizontalAlign="Center" />
<FooterStyle BackColor="#9CAAC1" Font-Bold="True" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="Black" Font-Names="Verdana" Font-Size="12px" />
<SelectedRowStyle BackColor="lightGray" Font-Bold="false" ForeColor="Black" Font-Names="Verdana"
Font-Size="12px" />
<Columns>
<asp:BoundField DataField="Prod_ID" HeaderText="Prod_ID" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="Prod_Name" HeaderText="Prod_Name" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Cust_Name" HeaderText="Cust_Name" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Price" HeaderText="Price" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Right" DataFormatString="{0:c}" />
<asp:TemplateField HeaderText="#" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
ItemStyle-VerticalAlign="Middle" HeaderStyle-Wrap="true" ItemStyle-Wrap="true">
<ItemTemplate>
<asp:Button ID="lnk_Save1" runat="server" OnClick="lnk_Save_Click"
Style="text-align: center; height: 25px;" ClientIDMode="Static" Text="Save">
</asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Configuration;
public partial class A_Gridview_Example1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Fill_GV();
}
}
public void Fill_GV()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[4] { new DataColumn("Prod_ID"), new DataColumn("Prod_Name"), new DataColumn("Cust_Name"), new DataColumn("Price") });
dt.Rows.Add(1, "Mobile", "Rajesh", "1000");
dt.Rows.Add(2, "Laptop", "Rajesh", "1000");
dt.Rows.Add(3, "TV", "Rajesh", "1000");
dt.Rows.Add(3, "TV", "Ram", "200");
dt.Rows.Add(3, "TV", "Raj", "1000");
dt.Rows.Add(2, "Laptop", "Seeta", "200");
dt.Rows.Add(3, "TV", "Seeta", "1000");
dt.Rows.Add(2, "Laptop", "Geeta", "1000");
dt = dt.Select("", "Cust_Name asc").CopyToDataTable();
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (TableCell tc in e.Row.Cells)
{
tc.Attributes["style"] = "border:1px solid black;";
}
if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
{
string Prod_ID = DataBinder.Eval(e.Row.DataItem, "Prod_ID").ToString();
string Prod_Name = DataBinder.Eval(e.Row.DataItem, "Prod_Name").ToString();
string Cust_Name = DataBinder.Eval(e.Row.DataItem, "Cust_Name").ToString();
Button lnk_Save1 = (Button)e.Row.FindControl("lnk_Save1");
}
}
protected void lnk_Save_Click(object sender, EventArgs e)
{
Button lnk = sender as Button;
GridViewRow GVR = (GridViewRow)lnk.NamingContainer;
GridView1.SelectedIndex = GVR.DataItemIndex;
string Row_Index = GVR.RowIndex.ToString();
string Prod_ID = GridView1.DataKeys[GVR.RowIndex].Values["Prod_ID"].ToString();
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
}