Adding button to single column in grid view.

Posted by Valley under ASP.NET AJAX on 5/2/2013 | Points: 10 | Views : 2531 | Status : [Member] | Replies : 2
I have Grid view with 9 columns. I have used Data source to pull the table from database. I am also using edit function in this table for updating information.
My question is I want to add a symbol in the notes column and display the information in that column after clicking on it (Popup is fine) . Can anyone help me with this issue?

Name Notes Notes DOB ID# Join End Gender Copay
Edit Sym Sym




Responses

Posted by: Valley on: 5/6/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Everyone,
I got the answer,

<asp:BoundField DataField="Notes" HeaderText="Notes" Visible="False"
SortExpression="Notes" />
<asp:BoundField DataField="Notes" HeaderText="Notes" Visible="False"
SortExpression="Notes" />
<asp:ButtonField ButtonType="Image" ImageUrl="~/Images/Imgs.jpg"
Text="Button" />
-----------------------------------------------------------------------------------------------------

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView1.Columns[2].Visible = true;
GridView1.Columns[3].Visible = true;
}

Valley, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Valley on: 5/6/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Everyone,

I am attaching a screenshot of my output. I have N rows and 9 columns. Two columns will be visible after clicking on the image. But I want the image to be visible only if there is text in those columns. Please help me.

Below is the code that I have used: Also please see the screenshot that I have attached.

<asp:BoundField DataField="Notes" HeaderText="Notes" Visible="False"
SortExpression="Notes" />
<asp:BoundField DataField="Notes" HeaderText="Notes" Visible="False"
SortExpression="Notes" />
<asp:ButtonField ButtonType="Image" ImageUrl="~/Images/Imgs.jpg"
Text="Button" />
-----------------------------------------------------------------------------------------------------

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView1.Columns[2].Visible = true;
GridView1.Columns[3].Visible = true;
}

 Download source file

Valley, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response