Dear Sir,
I am facing a problem. my
<asp:BoundField DataField="Country" HeaderText="Country" Visible="false" />
is not showing value in TextBox
Please help me to how to show value in textbox of visible=false filed.
<%-- Start Parts List for parts and labour --%>
<div class="container p-0 mb-0 mt-0">
<asp:Panel ID="Panel1" runat="server">
<div class="row p-0 g-0 bg-primary ">
<div class="col col-12 h-50 bg-primary text-center fs-6 text-white">
Parts Supplied
</div>
</div>
<div class="col col-12 text-black justify-content-center">
<asp:GridView ID="GridView1" runat="server"
GridLines="Both"
EmptyDataText="No Record Found"
EmptyDataRowStyle-ForeColor="Red"
EmptyDataRowStyle-Font-Bold="true"
EmptyDataRowStyle-BorderStyle="None"
CssClass="MyPartAndLabourDataGridViewListOne"
HorizontalAlign="Center"
AllowSorting="true" AutoPostBack="true"
AutoGenerateColumns="false">
<EmptyDataRowStyle BorderStyle="None" Font-Bold="True" ForeColor="Red"></EmptyDataRowStyle>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="Blue" Font-Names="Arial" Font-Size="12px" Font-Bold="True" ForeColor="Blue" />
<RowStyle CssClass="rows Fs-12-User"></RowStyle>
<Columns>
<asp:TemplateField HeaderText="Sr.No" ItemStyle-Width="20px" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblRowNumber" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="30px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Select">
<HeaderTemplate>
<asp:CheckBox ID="HeaderCheckBoxPartsPl" AutoPostBack="true"
runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckedPartsPl" runat="server" AutoPostBack="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="Customer Id" />
<asp:BoundField DataField="Name" HeaderText="Customer Name" />
<asp:BoundField DataField="Country" HeaderText="Country" Visible="false" />
<asp:BoundField DataField="Salary" HeaderText="Salary" Visible="false" />
<asp:BoundField DataField="Dist" HeaderText="Dist" />
</Columns>
</asp:GridView>
</div>
<br />
</asp:Panel>
</div>
<%-- End Parts List for parts and labour --%>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<br />
<asp:TextBox ID="TextBox1" Text="" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" Text="" runat="server"></asp:TextBox>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.PopulateGridView();
}
}
private void PopulateGridView()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[5] {
new DataColumn("Id"),
new DataColumn("Name"),
new DataColumn("Country"),
new DataColumn("Salary"),
new DataColumn("Dist")
});
dt.Rows.Add(1, "John Hammond", "United States", 70000, "MZN");
dt.Rows.Add(2, "Mudassar Khan", "India", 40000, "MRT");
dt.Rows.Add(3, "Suzanne Mathews", "France", 30000, "Sre");
dt.Rows.Add(4, "Robert Schidner", "Russia", 50000, "SML");
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chckrw = (CheckBox)row.FindControl("CheckedPartsPl");
if (chckrw.Checked)
{
TextBox1.Text = row.Cells[3].Text;
TextBox2.Text = row.Cells[4].Text;
}
}
}