I need to show an AjaxControlToolkit ModalPopupExtender control, when user checks/unchecks a CheckBox control that is inside a GridView as a TemplateField.
-- Updated on 24/05/2013
See final solution here...
We finally solved the problem. So I decided to post here the complete solution and the final code.
The GridView
<asp:GridView ID="gvDocs" runat="server" CssClass="grid" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
OnPageIndexChanging="gvDocs_PageIndexChanging"
OnSorting="gvDocs_Sorting"
OnRowDataBound="gvDocs_RowDataBound">
<AlternatingRowStyle CssClass="grid_row_alternate"/>
<HeaderStyle CssClass="grid_header" />
<RowStyle CssClass="grid_row" />
<SelectedRowStyle CssClass="grid_row_selected" />
<Columns>
<asp:BoundField DataField="ID"/>
<asp:BoundField DataField="COLUMN_A" SortExpression="COLUMN_A" HeaderText="COLUMN_A" />
<asp:BoundField DataField="COLUMN_B" SortExpression="COLUMN_B" HeaderText="COLUMN_B" />
<!-- TemplateField with the CheckBox and the ModalPopupExtender controls -->
<asp:TemplateField HeaderText="Check" SortExpression="CHECK_COLUMN">
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"/>
<!-- Modal Popup block -->
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground" DropShadow="True" TargetControlID="CheckBox1" PopupControlID="panModalPopup" CancelControlID="CancelButton"/>
<asp:Panel ID="panModalPopup" runat="server" style="display:none; text-align:left; width:400px; background-color:White; border-width:2px; border-color:#40A040; border-style:solid; padding:10px;">
Are you sure?
<br /><br />
<div style="text-align:right;">
<asp:Button ID="ConfirmButton" runat="server" Text="Confirm" OnClick="ConfirmButton_Click" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>'/>
<asp:Button ID="CancelButton" runat="server" Text="Cancel"/>
</div>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
The code behind
protected void gvDocs_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType.Equals(DataControlRowType.DataRow))
{
// Setting the CheckBox check reading the state from DB
CheckBox CheckBox1 = (CheckBox)e.Row.FindControl("CheckBox1");
CheckBox1.Checked = DataBinder.Eval(e.Row.DataItem, "CHECK_COLUMN").ToString() == "Y"; // Or any other value that works like true/false
}
}
protected void ConfirmButton_Click(object sender, EventArgs e)
{
string id = ((Button)sender).CommandArgument; // Get the ID column value
// Update the CHECK_COLUMN value on the DB or do whatever you want with the ID...
BindData(); // Method that do the GridView DataBind after the changes applied to the DB
}
Some things to know
1) The ModalPopupExtender1 control is inside the GridView TemplateField because it needs to have access to the CheckBox1 and its click event. It's probably not the best solution ever, but it works and so it would not affect to much on performance if your GridView is not too complicated and if it is paged.
2) In order to catch the ConfirmButton Click event, you have to remove the OKControlID property from the ModalPopupExtender control settings.
-- END
-- Updated on 22/05/2013
Then I need the ID of the corresponding row to make an UPDATE on the DB.
-- END
This is the GridView
<asp:GridView ID="gvDocs" runat="server" CssClass="grid" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
OnPageIndexChanging="gvDocs_PageIndexChanging"
OnSorting="gvDocs_Sorting"
OnRowDataBound="gvDocs_RowDataBound">
<AlternatingRowStyle CssClass="grid_row_alternate"/>
<HeaderStyle CssClass="grid_header" />
<RowStyle CssClass="grid_row" />
<SelectedRowStyle CssClass="grid_row_selected" />
<Columns>
<asp:BoundField DataField="ID_DOCUMENTO" Visible="False"/>
<asp:BoundField DataField="NUM_PROT" SortExpression="NUM_PROT" HeaderText="N. Prot." />
<asp:BoundField DataField="DATE_PROT" SortExpression="DATE_PROT" HeaderText="Data Prot." />
... some other BoundFields ...
<asp:TemplateField HeaderText="Da archiviare" SortExpression="DA_ARCHIVIARE">
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:CheckBox ID="chkArchiviare" runat="server" AutoPostBack="True" OnCheckedChanged="chkArchiviare_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
And this is the ModalPopup block
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="True" TargetControlID="panModalPopup" PopupControlID="panModalPopup" OkControlID="btnConferma" CancelControlID="btnAnnulla" />
<asp:Panel ID="panModalPopup" runat="server" style="display:none; width:400px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:20px;">
Are you sure?
<br /><br />
<div style="text-align:right;">
<asp:Button ID="btnConferma" runat="server" Text="Conferma" OnClick="btnConferma_Click"/>
<asp:Button ID="btnAnnulla" runat="server" Text="Annulla" OnClick="btnAnnulla_Click" />
</div>
</asp:Panel>
Now, I want to show the ModalPopup each time a checkbox is checked/unchecked and that popup have to show a confirmation message with 2 buttons: Confirm and Cancel.
Confirm have to do an update on the DB and then postback.
Cancel have only to hide the popup without postback.
I know that ModalPopupExtender listens to OnClick events. So, do I necessary need a Button, LinkButton, ImageButton, etc. or can I do what I want?
You are right, it listens to onclick events, but client-side ones, so, the target control of the extender can be anything you can click on, even a div or a label.
try to show/hide ModalPopupExtender1 from chkArchiviare_CheckedChanged event like this.
ModalPopupExtender1.show();
and
ModalPopupExtender1.hide();
take one Hidden button and make it as TargetControlID like this.
<asp:HiddenField ID="btnHiddenDtl1" runat="Server" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="True" TargetControlID="btnHiddenDtl1" PopupControlID="panModalPopup" OkControlID="btnConferma" CancelControlID="btnAnnulla" />
you need not to call cancel button click event to hide ModalPopupExtender1.
You no need to include ModalPopup Extender inside your GridView. You can bind check box control in template field in GridView and use OnCheckedChanged property in it...So template would be like below
<asp:TemplateField HeaderText="Da archiviare" SortExpression="DA_ARCHIVIARE">
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:CheckBox ID="chkArchiviare" runat="server"
OnCheckedChanged="chkArchiviare_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
After this you have to call show function on chkArchiviare_CheckedChanged event...like this
ModalPopupExtender1.Show();
Here ModalPopupExtender1 is ID of you ModalPopupExtender control.
One more thing you have to remember use one button on .aspx page. And pass this button ID into ModalPopupExtender TargetControlID... Like this
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="True"
TargetControlID="btnShowModalPopup" PopupControlID="panModalPopup"
OkControlID="btnConferma" CancelControlID="btnAnnulla" />
<asp:Panel ID="panModalPopup" runat="server" style="display:none; width:400px;
background-color:White; border-width:2px; border-color:Black; border-
style:solid; padding:20px;"> Are you sure?<br /><br />
<div style="text-align:right;">
<asp:Button ID="btnConferma" runat="server" Text="Conferma"
OnClick="btnConferma_Click"/>
<asp:Button ID="btnAnnulla" runat="server" Text="Annulla"
OnClick="btnAnnulla_Click" />
</div>
</asp:Panel>
Here Why Iam using this button?....There is no use of this button because we are using show() in codebehind...but if we are not pass button Id to ModapPopupExtender TargetControlId property. It will give you an error.
So using ModalPopupExtender in this way...you can use it with LinkButton, Label, Button. For more details with example, you can check the below link....
How to Use ModalPopup Extender into GridView
I hope this article will clear your all doubts....Enjoy and share this with others...Thanks!
Related
I have nested a Gridview2(child) and I want to get the checked rows on a button click.
When I try to access Gridview2 from button click event I am not able to do that. However, I can access the parent Gridview1.
Can somebody explain me how to get the Child Gridview's checked rows on button click.
Also, Button is a column header of child Gridview.
Here is my code.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
CellPadding="3" GridLines="Horizontal"
onrowdatabound="GridView1_RowDataBound" DataKeyNames="id1">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:collapseExpand('id1_<%# Eval("id1") %>');">
<img id="imageSubId_<%# Eval("id1") %>" alt="Click to show/hide orders" border="0"
src="Images/bullet_toggle_plus.jpg" /></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="id1" HeaderText="ID" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="rid1_<%# Eval("id1") %>" style="display: none; position: relative; left: 25px;">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" CellPadding="4" ForeColor="#333333"
GridLines="None" OnRowCommand="Gridview2_RowCommand">
<Columns>
<asp:BoundField DataField="fname" HeaderText="First Name" />
<asp:BoundField DataField="mname" HeaderText="Middle Name" />
<asp:BoundField DataField="lname" HeaderText="Last Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="checkselect" runat="server" />
</ItemTemplate>
<HeaderTemplate>
<asp:Button ID="Button4" runat="server" Text="Remove" CommandName="Split" OnClick="Button4_Click" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button4" PopupControlID="Panel1" CancelControlID="Button1">
</ajaxToolkit:ModalPopupExtender>
</HeaderTemplate>
</asp:TemplateField> </Columns></asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
What I'd do is add a CommandArgument to Button4's declaration that will allow me to find the related GridView2.
So, I'd use what you're using elsewhere, id1. Add CommandArgument='<%# Eval("id1") %>' to your Button4 declaration.
Now, in Button4_Click, you can cast the sender to a Button like so:
var button4 = (Button)sender;
Once you have button4 casted correctly to a Button, you can access the CommandArgument property.
var id1 = button4.CommandArgument;
Once you have id1, it's as simple as iterating through the parent GridView, GridView1. Looks like your second column is bound to id1 as well, so you'd do the following:
GridView foundGridView2;
foreach(GridViewRow gvr in GridView1.Rows)
{
if(gvr.RowType == DataControlRowType.DataRow && gvr.Cells[1].Text == id1)
{
foundGridView2 = gvr.FindControl("GridView2");
break; // Once we've found it, no need to iterate through other items
}
}
At this point, you now have access to your found GridView2, and you can iterate through the rows of GridView2 and check the checkboxes. Let me know if you need help doing that.
Adding to the answer because I think the parent GridView1 may be swallowing Button4's click:
Create an event handler for GridView1's OnRowCommand event.
In the resulting GridView1_RowCommand() method, use the following to handle JUST your Button4 Click event:
if(e.CommandName == "Split")
{
// At this point I would refactor out the code you put in Button4_Click
// into a separate method. I'll give you an example:
HandleButton4Click(e.CommandArgument); // e.CommandArgument will contain the id1
}
In my aspx page I have a RadPageView which contains RadWindow and the RadGrid is inside the RadWindow. (ie. RadMultiPage -> RadPageView -> RadWindow -> RadGrid).
<telerik:RadWindow EnableShadow="true" ShowContentDuringLoad="false" runat="server"
ReloadOnShow="true" Title="Standard Text: Add Observation." OpenerElementID="lnkObservationsText"
Behaviors="None" VisibleStatusbar="false" EnableViewState="true" ID="rdWndObservationText"
Skin="Web20" Modal="true" Width="600">
<ContentTemplate>
<div class="RadModalMainDiv">
<div>
<p>
Help text to go here....</p>
</div>
<div class="divStandardTextButtonList">
<asp:Button ID="btnObservationsTextSelect" runat="server" Text="Select" CssClass="btnStandardText"
OnClientClick="return ObservationStandardText_Confirm()" />
<asp:Button ID="btnObservationsTextCancel" runat="server" Text="Cancel" CssClass="btnStandardText" />
</div>
<asp:Panel ID="pnl1" runat="server">
<div>
<telerik:RadGrid ID="radGdObservationsText" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" GridLines="None" PageSize="10" Width="100%">
<MasterTableView CommandItemDisplay="None" Name="ParentGrid">
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
</telerik:GridClientSelectColumn>
<telerik:GridBoundColumn DataField="description" HeaderText="Observation Description"
Visible="true">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric" />
<ClientSettings>
<Selecting AllowRowSelect="True" />
<ClientEvents OnRowSelected="SetObservationStandardText" />
</ClientSettings>
</telerik:RadGrid>
</div>
</asp:Panel>
</div>
</ContentTemplate>
</telerik:RadWindow>
When I try to sort the grid clicking on the header, the page refreshes and the RadWindow disappears. Sorting happens coz when i reopens the RadGrid the rows appea sorted. I need the RadGrid to be sroted and remain in the same state.
Thanks for all helps in prior.
You have to reopen the RadWindow manually in order for this to work. I can suggest that you try an easier approach. Remove the OpenerElementID and modify the button that open the RadWindow and the other one that closes it as shown below:
Click handler for the button that open/close the window:
void lnkObservationsText_Click(object sender, EventArgs e)
{
rdWndObservationText.VisibleOnPageLoad = !rdWndObservationText.VisibleOnPageLoad;
}
Click handler code for the close button that resides in the RadWindow itself
void btnObservationsTextCancel_Click(object sender, EventArgs e)
{
rdWndObservationText.VisibleOnPageLoad = false;
}
In this case you won't need to use ReloadOnShow.
Hope this helps. Good luck :)
Hello fellow programmers, got a few problem here. I am adding a user control inside a gridview.
Now my question is how can bind it cause inside the user control is a gridviewthat needs the CourseCatID so that it could bind the datas. And by the way I cannot use nested griview cause I need the render of the nested usercontrol for another purpose. Any tutorial/help will be gladly appreciated.
<asp:GridView ID="grdCategory" runat="server" AutoGenerateColumns="False" Width="1100px"
DataKeyNames="CourseCatID" Font-Names="verdana,arial,helvetica,sans-serif" Font-Size="8pt"
CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:ButtonField Text="SingleClick" CommandName="SingleClick" Visible="False" />
<asp:BoundField HeaderText="CourseCatID" Visible = "false" DataField="CourseCatID" />
<asp:TemplateField HeaderText="Course Category">
<ItemTemplate>
<asp:Label ID="lblCourseCatID" runat="server" Visible="false" Text='<%# Eval("CourseCatID")%>'></asp:Label>
<a href="javascript:toggleDiv('mydiv<%# Eval("CourseCatID")%>')">
<asp:TextBox ID="txtCourseCatName" runat="server" Text='<%# Eval("CourseCatName") %>' Font-Size="XX-Small"
Font-Names="Verdana" Width="300px" Visible="false"></asp:TextBox>
<asp:Image ID="img" onclick="javascript:Toggle(this);" runat="server" ImageUrl="~/Images/minus.gif"
ToolTip="Collapse" Width="7px" Height="7px" ImageAlign="AbsMiddle" /></a>
<asp:Label ID="lbllastname" Height="15px" runat="server" Text='<%# Eval("CourseCatName")%>'> </asp:Label>
<div id="mydiv<%# Eval("CourseCatID")%>">
<br />
      <%--OnClick="ImageAdd_click" --%>
<asp:ImageButton ID="ImageAdd" Height="17px" ImageUrl="Images/addCourse.png" runat="server"
CommandName="cmdAdd" CommandArgument='<%# Eval("CourseCatID") %>' />
<br />
<br />
      
<asp:Panel ID="pnlCourse" runat="server"></asp:Panel>
<b><cuc1:CourseUserControl ID="CourseUserControl1" runat="server" /></b>
<br />
<br />
<br />
<br />
</div>
</ItemTemplate>
</asp:TemplateField>
Thank you for your time
You have a couple of options.
The easiest one is to expose a public property on the user control that will let you do this:
<cuc1:CourseUserControl ID="CourseUserControl1" runat="server" CourseCategoryID='<%# (int)Eval("CourseCatID") %>' />
Then databind in the user control as soon as that property is assigned to. Note that I'm assuming the category is an Int32. For example (note that the CourseCategoryID stores its value in a private field, not in ViewState):
private int _courseCategoryID;
public int CourseCategoryID
{
get { return _courseCategoryID; }
set
{
_courseCategoryID = value;
// TODO: code that initializes the GridView in user control.
this.DataBind();
}
}
Your other option is to expose the same property and handle the RowDataBound event and do this:
if (e.Row.RowType == DataControlType.DataRow)
{
CourseUserControl courseDetails;
courseDetails = (CourseUserControl)e.Row.FindItem("CourseUserControl1");
// Assuming category ID is Int32
courseDetails.CourseCategoryID = (int)grdCategory.DataKeys[e.Row.RowIndex].Value;
courseDetails.DataBind();
}
Note that I'm databinding manually instead of immediately after assigning a new category to the user control in the current row.
For more information, see:
GridView.RowDataBound Event (ASP.NET 3.5)
or
GridView.RowDataBound Event (ASP.NET 4.0)
I have GridView on my asp.net page, one column in that grid is ImageButton (TemplateField with ID="imbReserve"). On click on that button I want to show PopUp, but when I put TargetControlId="imbReserve" I get error message " A control with ID 'imbReserve' could not be found". How to achieve this, on click on button inside Grid show PopUp ?
Have a look at these 2 articles, that just helped me out with this problem
Article 1: A More Traditional approach
The Following is paraphrased from the above article
The Page Code:
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false"
Width="95%">
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Button ID="btnViewDetails" runat="server" Text="Details" OnClick="BtnViewDetails_Click" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="customerid" HeaderText="ID" />
<asp:BoundField DataField="companyname" HeaderText="Company" />
<asp:BoundField DataField="contactname" HeaderText="Name" />
<asp:BoundField DataField="contacttitle" HeaderText="Title" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<ajaxToolKit:ModalPopupExtender
ID="mdlPopup" runat="server" TargetControlID="pnlPopup" PopupControlID="pnlPopup"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlPopup" runat="server" Width="500px" style="display:none">
<asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional">
<ContentTemplate>
[Your Content Here]
</ContentTemplate>
</asp:UpdatePanel>
<div align="right" style="width:95%">
<asp:Button
ID="btnSave" runat="server" Text="Save" />
<asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" />
</div>
</asp:Panel>
Note that the GridView is wrapped in an update panel also that the Target Control ID for the Modal Extender is the same as the Pop Up Control ID. This is because the ModalPopUp Extender needs a target control ID and I think this solution is a better plan than using a hidden button.
Now For the Code Behind:
protected void BtnViewDetails_Click(object sender, EventArgs e)
{
// Do Anything you need to the contents of the update panel
// update the contents in the detail panel
this.updPnlCustomerDetail.Update();
// show the modal popup
this.mdlPopup.Show();
}
Article 2:Uses Clientside Javascript
The Following is paraphrased from the above article
The client side Javascript
<script type="text/javascript">
// keeps track of the delete button for the row
// that is going to be removed
var _source;
// keep track of the popup div
var _popup;
function showConfirm(source){
this._source = source;
this._popup = $find('mdlPopup');
// find the confirm ModalPopup and show it
this._popup.show();
}
function okClick(){
// find the confirm ModalPopup and hide it
this._popup.hide();
// use the cached button as the postback source
__doPostBack(this._source.name, '');
}
function cancelClick(){
// find the confirm ModalPopup and hide it
this._popup.hide();
// clear the event source
this._source = null;
this._popup = null;
}
Page Code:
<asp:GridView ID="gvToDoList" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="Item" HeaderText="Description" />
<asp:BoundField DataField="IsCompleted" HeaderText="Complete?" />
<asp:TemplateField ControlStyle-Width="50px" HeaderStyle-Width="60px" >
<ItemTemplate>
<asp:Button ID="btnDelete" runat="server"
OnClientClick="showConfirm(this); return false;"
OnClick="BtnDelete_Click" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<ajaxToolKit:ModalPopupExtender BehaviorID="mdlPopup" runat="server"
TargetControlID="div" PopupControlID="div"
OkControlID="btnOk" OnOkScript="okClick();"
CancelControlID="btnNo" OnCancelScript="cancelClick();"
BackgroundCssClass="modalBackground" />
<div id="div" runat="server" align="center" class="confirm" style="display:none">
<img align="absmiddle" src="Img/warning.jpg" />Are you sure you want to delete this item?
<asp:Button ID="btnOk" runat="server" Text="Yes" Width="50px" />
<asp:Button ID="btnNo" runat="server" Text="No" Width="50px" />
</div>
Again note that the Target Control ID for the Modal Pop Up Extender is the same as the Pop Up Control ID. Also note the OnClientClick attribute on the button in the template field, make sure your include "return false;".
All that is needed in the code behind it the onClick (or onCommand) event handler to do what you need to do.
I've tried both of these approaches successfully.
Hope one of these two works for you.
The problem is related to the fact that the real ID is getting changed when the page get rendered to the client.
Open your page source in the browser and look at the ID that is generated from asp.net. Then use that ID inside the TargetControlID property
This kind of problem is present with all the templated controls in ASP.NET
A cleaner way will be to bind the TargetControlID property of the ModalPopupExtendr on Page Load where you can use the ClientID property dinamically generated
modalPopupExtender.TargetControlID = myTemplateControl.ClientID;
I have an update panel with a gridview and some radios inside it. Senario is that when user select a radio, some bottoms get visible. But after radio eventhandler is trigered, updatepanel contents get dissapered. Any idea about this problem?
<asp:ScriptManager ID="scriptManager_main" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="updatePanel_main" runat="server">
<ContentTemplate>
<asp:GridView ID="gridView_stLists" runat="server" AutoGenerateColumns="False" CellPadding="3"
BorderStyle="NotSet" CssClass="table_layout" Width="500">
<RowStyle CssClass="table_body" />
<Columns>
<asp:TemplateField HeaderStyle-Width="20">
<ItemTemplate>
<asp:RadioButton ID="rdBtn_stdl" runat="server" OnCheckedChanged="rdBtn_stdl_CheckedChanged"
AutoPostBack="True" GroupName="stdl" value='<%# Eval("uri") %>' />
</ItemTemplate>
<HeaderStyle Width="20px" />
</asp:TemplateField>
...
The RadioButton is doing an AutoPostBack. Are you rebinding to the GridView after postback and thus overridding your changes/state? Only DataBind if !IsPostBack and this might address the issue.