I'm trying to help you with a sample of two controls and sample grid view ID 'GridView1' here, alter it according to your code:
You could either have the labels created instead of showing the text box in the CODE BEHIND or create both textboxes and labels initially and show them when needed.
Also instead of doing it in the Page_Load function you could do it in the 'RowDataBound' event of GridView and bind the GridView each every time a post back is done.
ASPX Code:
<ItemTemplate>
<asp:TextBox ID="Q1" runat="server" Text='<%# Bind("Q1") %>'></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Q1") %>' Visible="false">
</asp:Label>
</ItemTemplate>
.....
<ItemTemplate>
<asp:TextBox ID="Q2" runat="server" Text='<%# Bind("Q2") %>'></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Q2") %>' Visible="false">
</asp:Label>
</ItemTemplate>
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
//Bind your grid view
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int rowIndex = e.Row.RowIndex;
//First fetch your textboxes and labeles
TextBox textBoxQ1 = GridView1.Rows[rowIndex].FindControl("Q1") as TextBox;
TextBox textBoxQ2 = GridView1.Rows[rowIndex].FindControl("Q2") as TextBox;
Label Label1 = GridView1.Rows[rowIndex].FindControl("Label1") as Label;
Label Label2 = GridView1.Rows[rowIndex].FindControl("Label2") as Label;
if (Window_name.Equals("Q2"))
{
//Set 'visiblity' to 'true' for those LABEL you want to show. Sample one below
Label2.Visible = false;
//Set 'visibilty' to 'false' for those TEXT BOXES you want to hide. Sample one below
textBoxQ2.Visible = false;
}
}
Let me know in case of any queries.