Gridview conditionall showing select button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to conditionally show the select button.

I don't want to show (or at lease disable) the select button based on the
data I am retrieving in that row.

Any help is appreciated.

Thanks
 
Tyler said:
Is there a way to conditionally show the select button.

I don't want to show (or at lease disable) the select button based on the
data I am retrieving in that row.

Any help is appreciated.

Thanks

Clear the cell contained the select button on RowDataBound.
Example:
html
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (needToHideCondition)
e.Row.Cells[0].Text = "";
}
}
 
Thanks a bunch
--
Tyler


marss said:
Is there a way to conditionally show the select button.

I don't want to show (or at lease disable) the select button based on the
data I am retrieving in that row.

Any help is appreciated.

Thanks

Clear the cell contained the select button on RowDataBound.
Example:
html
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (needToHideCondition)
e.Row.Cells[0].Text = "";
}
}
 
How about if we have 3 buttons (select, delete, and edit), and we want to
only disable one of them (ex. delete) in some conditioins?

marss said:
Is there a way to conditionally show the select button.

I don't want to show (or at lease disable) the select button based on the
data I am retrieving in that row.

Any help is appreciated.

Thanks

Clear the cell contained the select button on RowDataBound.
Example:
html
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (needToHideCondition)
e.Row.Cells[0].Text = "";
}
}
 
Back
Top