I am trying to hide the Telerik RadGrid Edit column until the user clicks on the row the user wants to edit. Upon the click event I need the Edit hyperlink column set to Visible="true". I was hoping to set the column as Visible="false" by default, and then add a click event in my .cs page to alter the visibility property, but I cannot figure out how to target the edit column... Here is my code for the .aspx page.
<telerik:RadGrid ID="RG_POI" runat="server" OnPreRender="RG_POI_PreRender" OnItemDataBound="RG_POI_ItemDataBound" >
<MasterTableView EditMode="InPlace" >
<Columns>
<telerik:GridEditCommandColumn Visible="false"/>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
You can do this via C# or JavaScript. If you use C#, you can remove the OnRowSelected="gridSelected" from the grid definition below; if you use JavaScript then remove the OnSelectedIndexChanged="rgTest_SelectedIndexChanged":
ASPX:
<telerik:RadGrid ID="RG_POI" ... OnSelectedIndexChanged="rgTest_SelectedIndexChanged">
<ClientSettings ... >
<ClientEvents OnGridCreated="gridCreated" OnRowSelected="gridSelected" />
</ClientSettings>
<MasterTableView ... >
<Columns>
<telerik:GridEditCommandColumn UniqueName="Edit" />
...
Option 1) C#:
protected void rgTest_SelectedIndexChanged(object sender, EventArgs e)
{
RG_POI.Columns[1].Visible = true;
}
Option 2) JavaScript:
function gridCreated(menu, args) {
var radGrid = $find('RG_POI');
var table = radGrid.get_masterTableView();
table.shideColumn(1);
}
function gridSelected(menu, args) {
var radGrid = $find('RG_POI');
var table = radGrid.get_masterTableView();
table.showColumn(1);
}
Related
I have a grid with the following definition. I have included two buttons here (different types), but I really only want one, but it must be able to be hidden under certain circumstances.
With the 'ButtonField' I was able to hide it in the RowDataBound event, however, on postback (row click event), all buttons where displayed.
Clicking this button triggers two RowCommand events, one being 'Select' and one being the 'AcceptStats', which would be okay if I could hide the button when not wanted.
The 'asp:Button' displays correctly all the time, but the click event seems to have gotten lost under the row click event.
In the RowCommand event, the CommandName is always 'Select', which comes from the row click event.
I have tried adding OnClick="btnAcceptStats_Click" to the asp:Button, but it doesn't trigger either.
<asp:GridView ID="gvApsimFiles" runat="server" AutoGenerateColumns="false" CssClass="GridViewStyle"
PageSize="10" AllowPaging="true" DataKeyNames="PullRequestId, RunDate"
OnPageIndexChanging="gvApsimFiles_PageIndexChanging"
OnRowCommand="gvApsimFiles_RowCommand"
OnRowDataBound="gvApsimFiles_RowDataBound"
OnSelectedIndexChanged="gvApsimFiles_SelectedIndexChanged" >
<HeaderStyle CssClass="GridViewHeaderStyle" />
<Columns>
<asp:BoundField DataField="PullRequestId" HeaderText="Pull Request Id" ItemStyle-Width="100px" />
<asp:BoundField DataField="RunDate" HtmlEncode="false" HeaderText="Run Date" ItemStyle-Width="220px" DataFormatString="{0:d MMMM, yyyy hh:mm tt}" />
<asp:BoundField DataField="IsMerged" HeaderText="Is Merged" ItemStyle-Width="100px" />
<asp:BoundField DataField="PercentPassed" HtmlEncode="false" HeaderText="Percent<br />Passed" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
<asp:BoundField DataField="Total" HeaderText="Total Files" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
<asp:ButtonField ButtonType="Button" ItemStyle-Font-Size="11px" Text="Accept Stats" CommandName="AcceptStats" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnAcceptStats" runat="server" Text="Accept Stats"
CommandName="AcceptStats"
CommandArgument='<%# Container.DataItemIndex %>'
OnClick="btnAcceptStats_Click"
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
In the code behind:
protected void btnAcceptStats_Click(object sender, EventArgs e)
{
GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
int index = gvRow.RowIndex;
int pullRequestId = int.Parse(gvApsimFiles.Rows[index].Cells[0].Text);
//Now we can call our web api 'merge' call
bool mergeStatus = bool.Parse(gvApsimFiles.Rows[index].Cells[2].Text);
if (!mergeStatus)
{
UpdatePullRequestMergeStatus(pullRequestId, true);
}
}
protected void gvApsimFiles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvApsimFiles.PageIndex = e.NewPageIndex;
BindApsimFilesGrid();
}
protected void gvApsimFiles_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "AcceptStats")
{
var eVal = Convert.ToInt32(e.CommandArgument);
int index = int.Parse(eVal.ToString());
int pullRequestId = int.Parse(gvApsimFiles.Rows[index].Cells[0].Text);
//Now we can call our web api 'merge' call
bool mergeStatus = bool.Parse(gvApsimFiles.Rows[index].Cells[2].Text);
if (!mergeStatus)
{
UpdatePullRequestMergeStatus(pullRequestId, true);
}
}
}
protected void gvApsimFiles_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Show as green if 100%
if (e.Row.Cells[3].Text.Equals("100"))
{
e.Row.ForeColor = Color.Green;
}
//Activate the row click event
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvApsimFiles, "Select$" + e.Row.RowIndex);
e.Row.Attributes["style"] = "cursor:pointer";
}
}
Is there a way that I can have a button, that is only displayed when required, doesn't re-appear on postback, and triggers correctly, while maintaining the row click event?
If you want to hide buttons, why not base their visibility on a value of the GridView inline.
<asp:Button ID="Button2" runat="server" Visible='<%# Convert.ToBoolean(Eval("myBool")) %>' Text="Button 1" />
<asp:Button ID="Button1" runat="server" Visible='<%# !Convert.ToBoolean(Eval("myBool")) %>' Text="Button 2" />
Thanks for your response. I have the asp:Button displaying correctly with the following code:
visible='<%# Eval("IsMerged").ToString().ToLowerInvariant().Equals("false") %>'
The problem is that, when I use this button, I cannot get the Button Click event to work, only the row click event. When I step through the RowCommand the CommandName is only ever 'Select'. I am not able to trigger the 'AcceptStats' event.
I have found a solution. It is through the use of Gridview_RowDataBound, updating each cell in the grid, and then on the Gridview_RowCommand, retrieving these values, and going from there.
It is slightly slower to load, but works. The working code on the .aspx page is as follows:
<asp:GridView ID="gvApsimFiles" runat="server" AutoGenerateColumns="false" CssClass="GridViewStyle"
PageSize="10" AllowPaging="true" DataKeyNames="PullRequestId, RunDate"
OnPageIndexChanging="gvApsimFiles_PageIndexChanging"
OnRowCommand="gvApsimFiles_RowCommand"
OnRowDataBound="gvApsimFiles_RowDataBound" >
<HeaderStyle CssClass="GridViewHeaderStyle" />
<RowStyle CssClass="GridViewRowStyle" />
<Columns>
<asp:BoundField DataField="PullRequestId" HeaderText="Pull Request Id" ItemStyle-Width="100px" />
<asp:BoundField DataField="RunDate" HtmlEncode="false" HeaderText="Run Date" ItemStyle-Width="220px" DataFormatString="{0:d MMMM, yyyy hh:mm tt}" />
<asp:BoundField DataField="IsMerged" HeaderText="Is Merged" ItemStyle-Width="100px" />
<asp:BoundField DataField="PercentPassed" HtmlEncode="false" HeaderText="Percent<br />Passed" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
<asp:BoundField DataField="Total" HeaderText="Total Files" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnAcceptStats" runat="server" Text="Accept Stats"
Visible='<%# Eval("IsMerged").ToString().ToLowerInvariant().Equals("false") %>'
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
with the code behind being:
protected void gvApsimFiles_RowCommand(object sender, GridViewCommandEventArgs e)
{
// Don't interfere with other commands.
// We may not have any now, but this is another safe-code strategy.
if (e.CommandName == "CellSelect")
{
// Unpack the arguments.
String[] arguments = ((String)e.CommandArgument).Split(new char[] { ',' });
// More safe coding: Don't assume there are at least 2 arguments.
// (And ignore when there are more.)
if (arguments.Length >= 2)
{
// And even more safe coding: Don't assume the arguments are proper int values.
int rowIndex = -1, cellIndex = -1;
bool canUpdate = false;
int.TryParse(arguments[0], out rowIndex);
int.TryParse(arguments[1], out cellIndex);
bool.TryParse(arguments[2], out canUpdate);
// Use the rowIndex to select the Row, like Select would do.
if (rowIndex > -1 && rowIndex < gvApsimFiles.Rows.Count)
{
gvApsimFiles.SelectedIndex = rowIndex;
}
//here we either update the Update Panel (if the user clicks only anything OTHER THAN our'Button'
//or we process the UpdatePullRequest as Merged
if (cellIndex == 5 && canUpdate == true)
{
int pullRequestId = int.Parse(gvApsimFiles.Rows[rowIndex].Cells[0].Text);
UpdatePullRequestMergeStatus(pullRequestId, true);
}
else
{
int pullRequestId = int.Parse(gvApsimFiles.Rows[rowIndex].Cells[0].Text);
BindSimFilesGrid(pullRequestId);
}
}
}
}
protected void gvApsimFiles_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Show as green if 100%
if (e.Row.Cells[3].Text.Equals("100"))
{
e.Row.ForeColor = Color.Green;
}
e.Row.Attributes["style"] = "cursor:pointer";
//Active cell click events on individual cells, instead of the row
foreach (TableCell cell in e.Row.Cells)
{
// Although we already know this should be the case, make safe code. Makes copying for reuse a lot easier.
if (cell is DataControlFieldCell)
{
int cellIndex = e.Row.Cells.GetCellIndex(cell);
bool canUpdate = false;
// if we are binding the 'Button' column, and the "IsMerged' is false, then whe can Update the Merge Status.
if (cellIndex == 5 && e.Row.Cells[2].Text.ToLower().Equals("false"))
{
canUpdate = true;
}
// Put the link on the cell.
cell.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvApsimFiles, String.Format("CellSelect${0},{1},{2}", e.Row.RowIndex, cellIndex, canUpdate));
// Register for event validation: This will keep ASP from giving nasty errors from getting events from controls that shouldn't be sending any.
Page.ClientScript.RegisterForEventValidation(gvApsimFiles.UniqueID, String.Format("CellSelect${0},{1},{2}", e.Row.RowIndex, cellIndex, canUpdate));
}
}
}
}
I have a gridview1 control and I want use the values in some columns, but I also want to hide these columns because the users do not need to see them and they also take up too much space in the display. However, when I hide the column and I try to use the value from the column I get the error "Input string was not in a correct format".
//Here is the example of one column which I defined not visible:
<asp:GridView ID="GridView9" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource9" OnSelectedIndexChanged="GridView9_SelectedIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="WORKORDER_BASE_ID" HeaderText="WORKORDER_BASE_ID" SortExpression="WORKORDER_BASE_ID" />
<asp:BoundField DataField="WORKORDER_LOT_ID" HeaderText="WORKORDER_LOT_ID" SortExpression="WORKORDER_LOT_ID" Visible="False" />
<asp:BoundField DataField="WORKORDER_SPLIT_ID" HeaderText="WORKORDER_SPLIT_ID" SortExpression="WORKORDER_SPLIT_ID" Visible="False" />
<asp:BoundField DataField="WORKORDER_SUB_ID" HeaderText="WORKORDER_SUB_ID" SortExpression="WORKORDER_SUB_ID" Visible="False" />
<asp:BoundField DataField="SEQUENCE_NO" HeaderText="SEQUENCE_NO" SortExpression="SEQUENCE_NO" />
<asp:BoundField DataField="RESOURCE_ID" HeaderText="RESOURCE_ID" SortExpression="RESOURCE_ID" Visible="False" />
<asp:BoundField DataField="STATUS" HeaderText="STATUS" SortExpression="STATUS" Visible="False" />
<asp:BoundField DataField="RUN_COST_PER_HR" HeaderText="RUN_COST_PER_HR" SortExpression="RUN_COST_PER_HR" Visible="False"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource9" runat="server" ConnectionString="<%$ ConnectionStrings:xyzConnectionString %>" SelectCommand="SELECT [WORKORDER_BASE_ID], [WORKORDER_LOT_ID], [WORKORDER_SPLIT_ID], [WORKORDER_SUB_ID], [SEQUENCE_NO], [RESOURCE_ID], [STATUS], [RUN_COST_PER_HR] FROM [OPERATION] WHERE (([STATUS] = #STATUS) AND ([RESOURCE_ID] = #RESOURCE_ID))">
<SelectParameters>
<asp:Parameter DefaultValue="R" Name="STATUS" Type="String" />
<asp:Parameter DefaultValue="XYZIBRA" Name="RESOURCE_ID" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
// then later I do this:
vHOURLY_COST = Convert.ToDecimal(GridView9.SelectedRow.Cells[8].Text);
If I remove the Visible="False" then the code executes successfully.
I found that once I make the column visible = false and the values for the column that is not visible becomes NULL, therefore I get the error "Input string was not in a correct format".
The question is how do I retrieve the column value and make the column not visible?
Haven't got time to investigate properly, but from what I understand, if you have set Visible=False then the asp control will not be rendered at all to the page. You're probably trying to convert an empty string to decimal.
Perhaps you could keep the original dataset in the Session variable or use CSS to hide the unwanted columns.
There are a couple of ways of getting to values that you do not want displayed depending on where you need access to the values.
First things first. If your datasource provides four fields [A,B,C,D] and your Gridview is bound to two fields [A,B] fields [C,D] are still available to use...depending on where you need them.
They are all available in the RowDataBound event:
Datasource
--I'm assuming you have some data source that provides the equivalent of
SELECT A,B,C,D from <your_table>
Markup in .aspx
<%-- Fields A, B will be visible in GridView1.
Fields C, D will be NOT visible in GridView1 but are available in the code behind.
--%>
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="A" HeaderText="Field A" />
<asp:BoundField DataField="B" HeaderText="Field B" />
</Columns>
</asp:GridView>
Code Behind
protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e )
{
if ( e.Row.RowType == DataControlRowType.DataRow )
{
// How to access the undisplayed fields
DataRowView drv = (DataRowView) e.Row.DataItem;
String FieldC = drv["C"];
String FieldD = drv["D"];
// How to persist data for access elsewhere in the code behind.
// this will attach data to the <tr> tag in each data row
e.Row.Attributes["field-c"] = FieldC
e.Row.Attributes["field-d"] = FieldD
}
}
Alternatively, if you are not using the Editing features built into a gridview you can add the needed fields as data keys in the gridview:
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"
DataKeyNames="C,D">
. . .
</asp:GridView>
Which will make the needed fields from a selected GridView row available via GridView1.SelectedDataKey:
protected void btnSomeButton_Click( object sender, EventArgs e )
{
if( Gridview1.SelectedDataKey != null)
{
String FieldC = (String) GridView1.SelectedDataKey.Values[ "C" ];
String FieldD = (String) GridView1.SelectedDataKey.Values[ "D" ];
}
}
Using the DataKeyNames property is not recommended if you plan on using the built in editing of a gridview as this property is intended for database primary keys. Adding extra data complicates automation of the Insert/Update/Delete commands.
I found this:
[ASP.NET: GridView value set to null when column is not visible
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[1].Visible = false;
e.Row.Cells[2].Visible = false;
}
But I just didn't know how to implement the GridView9_RowCreated event until now. I changed my very first line of the code to:
<asp:GridView ID="GridView9" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource9" OnRowCreated="GridView9_RowCreated" OnSelectedIndexChanged="GridView9_SelectedIndexChanged">
I tested it and it holds all column values and hides the columns.
I have 2 gridviews. The first one is visible and second one is not.
What I want is:- When I click on any row of the first gridview, the relevant data should get open in the another gridview.
I haven't done this before. Here is my html
<cc1:Grid ID="GridFirst" runat="server" FolderStyle="../Styles/Grid/style_12" AutoGenerateColumns="false"
AllowAddingRecords="false" AllowColumnResizing="true" Width="40%" ShowFooter="true"
ShowHeader="true" OnRowDataBound="GridFirst_RowDataBound" AllowRecordSelection="true">
<Columns>
<cc1:Column ID="Column1" DataField="Sr_NO" Wrap="true" ReadOnly="true" HeaderText="Sr No"
Width="4%">
</cc1:Column>
<cc1:Column ID="Column2" DataField="Type" Wrap="true" HeaderText="Type" Width="10%">
</cc1:Column>
<cc1:Column ID="Column3" DataField="Date" Wrap="true" HeaderText="Date" Width="10%">
</cc1:Column>
</Columns>
</cc1:Grid>
On GridFirst_RowDataBound event
protected void GridFirst_RowDataBound(object sender, Obout.Grid.GridRowEventArgs e)
{
// open second gridview with relevant data here
}
Use GridView SelectedValue property if your GridView has DataKeyNames property set as follows:
protected void grdClient_SelectedIndexChanged(object sender, EventArgs e)
{
if(grdClient.SelectedValue != null)
{
Project ObjProject = new Project();
int userClientID. = int .Parse(grdClient.SelectedValue.ToString());
ObjProject.UserClientID = userClientID;
grdProject.DataSource = ObjProject.GetProjectList();
grdProject.DataBind();
}
}
Initially make the second GridView visible false and OnRowClick make it visible true.
The RowDataBound event is fired each time a row has been filled with data (basically when you call gridview.DataBind());
It is not here you want to put the code to display the second gridview on a user event.
I think you should use RowCommand with a parameter.
In your aspx :
Add to your gridview :
OnRowCommand="myMethod_Rowcommand"
Try first with a clickable button on each row (and when you click on it, it will trigger the command), add these attributes :
CommandName="DisplaySecondGrid" CommandArgument='<%#Eval("yourId") %>'
Then in your code behind
if(e.CommandName == "DisplaySecondGrid")
{
var id = e.CommandArgument.ToString();
var myData = repository.GetData(id);
secondGridView.DataSource = myData;
secondGridView.DataBind();
secondGridView.Visible = true;
}
Something like this should do the trick
My problem is that when I try to click the combobox within my Radgrid, it doesn't do anything.
<telerik:RadGrid ID="RadGrid" runat="server" DataSourceID="TestReleaseInformationSource" ShowStatusBar="true"
OnItemCommand="RadGridItemCommand" OnPreRender="RadGrid_PreRender" AllowAutomaticUpdates="true" EnableLinqExpressions="false"
AllowAutomaticDeletes="true" AllowPaging="true" AutoGenerateColumns="false" AllowFilteringByColumn="true">
<MasterTableView DataKeyNames="PrimaryKey">
<Columns>
<telerik:GridBoundColumn AllowFiltering="true" UniqueName="TeacherLastName" DataField="TeacherLastName" HeaderText="Last Name">
<FilterTemplate>
<telerik:RadComboBox ID="radComboBoxLastName" DataSourceID="TeacherLastNameDDL" DataTextField="TeacherLastName" DataValueField="TeacherLastName"
AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("TeacherLastName").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="TeacherLastNameChanged">
<Items>
<telerik:RadComboBoxItem Text="All" Selected="true" />
</Items>
</telerik:RadComboBox>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function TeacherLastNameChanged(sender, args)
{
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("TeacherLastName", args.get_item().get_value(), "EqualTo");
}
</script>
</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridBoundColumn>
On prerender of the grid
protected void RadGrid_PreRender(object sender, EventArgs e)
{
if (RadGrid.EditItems.Count > 0)
{
GridNestedViewItem item = (GridNestedViewItem)RadGrid.MasterTableView.GetItems(GridItemType.NestedView)[Convert.ToInt32(RadGrid.EditIndexes[0])];
item.Visible = false;
}
if (RadGrid.MasterTableView.FilterExpression != string.Empty)
{
RefreshCombos();
}
}
protected void RefreshCombos()
{
TestReleaseInformationSource.SelectCommand = TestReleaseInformationSource.SelectCommand + " WHERE " + RadGrid.MasterTableView.FilterExpression.ToString();
RadGrid.MasterTableView.Rebind();
}
I've stared at this for hours and can not figure out what the problem is. Any thoughts would be appreciated. Will post more code if necessary.
A solution I have found is to set the RenderMode property of the combobox to native. I would still like a different workaround.
Try making the JS functions unique: http://www.telerik.com/support/kb/details/using-dynamic-unique-names-for-javascript-functions
I think that all of them override each other so only the last one is active so only that executes. Also, look for JS errors.
Also, try invoking the filtering from the client as shown here http://www.telerik.com/help/aspnet-ajax/grid-client-side-binding-adding-sort-filter-expressions.html.
The masterTableView object is best obtained via the get_masterTableView() method of the main grid object.
ok so I have this ASP:Table which pulls its rows of info from a stored procedure query, only two columns but wish to add a third with a button for each row that when clicked will grab the information in the prior columns for use in another function.
not sure how the hell to code it though as the buttons are generated per row and how can I programme events for a unknown number of buttons there must be a way of doing It programmatically.
Table Header
Datacolumn1 Datacolumn2
a 2 Select
b 4 Select
e 9 Select
so when I press select on the second row it gives me string1=b string2=4
I imagine the code would look something like this (not likely but in a ideal world :D)
protected void select_row (eventargs as e)
{
string data1 = Row(e).cell(0).text
int data2 = Row(e).cell(1).text
}
For a grid like this
<asp:GridView ID="Grid1" runat="server" onrowcommand="Grid1_RowCommand" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Datacolumn1" HeaderText="Data column1" />
<asp:BoundField DataField="Datacolumn2" HeaderText="Data column2" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" CommandName="SelectIt" Text="Select" CommandArgument='<%# Eval("Datacolumn1") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Use RowCommand event
protected void Grid1_RowCommand(object sender, GridViewCommandEventArgs e)
{
var btn = (Button)e.CommandSource ;
if (e.CommandName == "SelectIt")
{
var Row =(GridViewRow) btn.NamingContainer;
var Datacolumn1 = Row.Cells[0].Text;
var Datacolumn2 = Row.Cells[1].Text;
btn.Text = "selected: " + Datacolumn1 + "," + Datacolumn2;
}
}