Telerik RadGrid (using Batch Edit) Hide / Disable Column Based on Another Column's Value - telerik

I'm trying to get RadGrid to conditionally hide or disable a field when it is in edit mode based on the value of another field.
I have been able to get this to work when the grid displays the list of items, but once the grid enters edit mode, the columns display ...
I am using OnItemDataBound to successfully conditionally display during the initial load, but setting the items when the user clicks a row to get it into batch mode is not working.
Note: PValue and CValue and in GridTemplateColumns, as is CardStatus.
public void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
foreach (GridDataItem item in RadGrid1.Items)
{
string BoundColumnValue = item["CardStatus"].Text; // accessing GridBoundColumn value using ColumnUniqueName
string BoundColumnValue2 = item["CValue"].Text;
TextBox txtbx = (TextBox)item.FindControl("CardStatus");
Label numlb = (Label)item.FindControl("CardValue");
if (txtbx.Text.Equals("True"))
{
txtbx.ForeColor = Color.Red;
numlb.Enabled = false;
numlb.BackColor = Color.Yellow;
numlb.ForeColor = Color.Red;
//Just testing to see if it would evaluate
}
else
{
txtbx.ForeColor = Color.Beige;
}
//string TemplateColumnValue = lb.Text;// accessing Label Text.
}
foreach (GridEditableItem item in RadGrid1.EditItems)
{
string BoundColumnValue = item["CardStatus"].Text; // accessing GridBoundColumn value using ColumnUniqueName
string BoundColumnValue2 = item["CValue"].Text;
TextBox txtbx = (TextBox)item.FindControl("CardStatus");
if (txtbx.Text.Equals("True"))
{
txtbx.ForeColor = Color.Red;
//numTxt.BackColor = Color.Yellow;
//numTxt.ForeColor = Color.Red;
}
else
{
txtbx.ForeColor = Color.Beige;
}
}
}
I just need to be able to selectively prevent data entry in a column
The ASPX source is below:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticUpdates="true" Height="930px" DataSourceID="SqlDataSource4" CellSpacing="0" GridLines="None" Width="640px" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated" OnBatchEditCommand="RadGrid1_BatchEditCommand1" Skin="WebBlue">
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView AutoGenerateColumns="False" EditMode="Batch" Width="620px" CommandItemDisplay="TopAndBottom" DataSourceID="SqlDataSource4" DataKeyNames="CountKey">
<CommandItemSettings ExportToPdfText="Export to PDF" ShowSaveChangesButton="true" ShowRefreshButton="false" ShowAddNewRecordButton="false"></CommandItemSettings>
<BatchEditingSettings OpenEditingEvent="Click" EditType="Row" />
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
<Columns>
<telerik:GridBoundColumn DataField="Pcolumn" ItemStyle-Width="75px" ReadOnly="true" Visible="false" DataType="System.Int32" FilterControlAltText="Filter Pcolumn column" HeaderText="Pcolumn" SortExpression="Pcolumn" UniqueName="Pcolumn">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Row" ReadOnly="true" Visible="false" DataType="System.Int32" FilterControlAltText="Filter Row column" HeaderText="Row" SortExpression="Row" UniqueName="Row">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn ColumnEditorID="PValue" HeaderText="Pattern" DataField="PValue" UniqueName="PValue" ItemStyle-Width="75px" HeaderStyle-Width="75px">
<EditItemTemplate>
<telerik:RadNumericTextBox ID="PValue" Width="50px" runat="server" MaxLength="1" MaxValue="9" NumberFormat-DecimalDigits="0" Text='<%# Bind("PValue") %>'></telerik:RadNumericTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="PValue" ErrorMessage="<br/>Required (0-9) Only)!" SetFocusOnError="true"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="PValue" Width="50px" runat="server" Text='<%# Bind("PValue") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn ColumnEditorID="CValue" DataField="CValue" HeaderText="Card" UniqueName="CValue" ItemStyle-Width="75px" HeaderStyle-Width="75px">
<EditItemTemplate>
<telerik:RadNumericTextBox ID="CValue" Width="50px" AllowOutOfRangeAutoCorrect="false" runat="server" MaxLength="1" MaxValue="1" NumberFormat-DecimalDigits="0" Text='<%# Bind("CValue") %>'></telerik:RadNumericTextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="CValue" ErrorMessage="<br />Required (0-1 Only)!" SetFocusOnError="true"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="CValue" Width="50px" runat="server" Text='<%# Bind("CValue") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="DateEdited" ReadOnly="true" Visible="false" DataType="System.DateTime" FilterControlAltText="Filter DateEdited column" HeaderText="DateEdited" SortExpression="DateEdited" UniqueName="DateEdited">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="CardStatus" DataField="CardStatus" ItemStyle-Width="50px" HeaderStyle-Width="50px">
<ItemTemplate>
<asp:TextBox ID="CardStatus" Width="10px" runat="server" Text='<%# Bind("CardStatus") %>'></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="CardStatus" Width="10px" runat="server" Text='<%# Bind("CardStatus") %>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
Any help / workarounds would be appreciated ... again, "just" need to prevent editing in the CValue column when the CardStatus value is true (bit field) ... using batch mode (using another solution isn't an option now).
Thanks
Larry

Well, this doesn't answer the Telerik question, but ended up doing this with the MS GridView, using the tutorial here: http://msdn.microsoft.com/en-us/library/aa992036(v=vs.90).aspx.
Also was able to customize, and detect hidden grid fields, and hide cells (and disable validators) based on the hidden field's condition.
Added the following code in the RowDataBound event of the gridview:
DataRowView drv = (DataRowView)e.Row.DataItem;
if (drv["Status"].Equals(true))
{
// Find the order of the cell
e.Row.Cells[5].CssClass = "hiddencol"; // using the display: none style
// Find the Validator control in the template column
RequiredFieldValidator reqF = (RequiredFieldValidator)e.Row.Cells[5].FindControl("RequiredFieldValidator1");
reqF.Enabled = false;
}
else
{
}

Related

Rebind detailtable in radgrid

i have a radgrid with detailtables ,
detailTable has "GridEditCommandColumn" and another "GridTemplateColumn" that contains linkbutton to remove row ,
<MasterTableView DataKeyNames="FEATURE_ID">
<Columns>
<telerik:GridBoundColumn DataField="FEATURE_ID" UniqueName="FeatureID" ></telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView ShowHeader="true" CommandItemDisplay="Top"
SkinID="RadGridSkin" Width="100%" runat="server" Name="Fees"
EditMode="InPlace">
<Columns>
<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="FEE_TEMPLATE_ID" UniqueName="FeeID"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="DeleteFee">
<ItemTemplate>
<asp:LinkButton ID="RemoveFee" runat="server" CommandName="RemoveFee" Text="RemoveFee" ImageUrl="../../../images/cancel.png" ToolTip="<%$Resources:Strings,remove %>" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
in code behind in itemCommand event :
dataSource of radgrid is updated and Datable.acceptchanges() is called ;
how to rebind only the detailTable where changes have occurred ??
You didn't supply the name of your RadGrid, but the first thing I would try is:
RadGrid1.MasterTableView.DetailTables(0).Rebind(),
or, although I'm not sure whether this works for you (it compiles in VS for me), you might be able to say:
RadGrid1.MasterTableView.DetailTables("Fees").Rebind().
Obviously, replace 'RadGrid1' with the name of your RadGrid.

Rad Grid Pager With Web Api

I try using Rad Grid with web Api as data source
<telerik:RadGrid runat="server" ID="grdUsers" AllowPaging="true" AllowSorting="true"
AllowFilteringByColumn="true" PageSize="5">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" ClientDataKeyNames="Id,PasswordHash">
<PagerStyle Mode="NumericPages" AlwaysVisible="true" />
<Columns>
<telerik:GridImageColumn DataType="System.String" DataImageUrlFields="Image" AlternateText="User image"
UniqueName="Image"
ImageAlign="Middle" ImageHeight="50px" ImageWidth="50px" AllowFiltering="false" HeaderText="">
</telerik:GridImageColumn>
<telerik:GridBoundColumn DataField="UserName" HeaderText="User Name" UniqueName="UserName"
DataType="System.String">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FullName" HeaderText="Name" UniqueName="FullName"
DataType="System.String">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Email" HeaderText="Email" UniqueName="Email"
DataType="System.String">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="RegistrationDate" HeaderText="Registration Date" UniqueName="RegistrationDate"
DataFormatString="{0:dd/MM/yyyy}">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn UniqueName="btnEdit" ButtonType="PushButton" Text="Edit" CommandName="Edit"></telerik:GridButtonColumn>
<telerik:GridButtonColumn UniqueName="btnDelete" ButtonCssClass="del" ButtonType="PushButton" Text="Delete" CommandName="Delete"></telerik:GridButtonColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
<ClientEvents OnCommand="RadGridCommand" />
<DataBinding Location="/SecuHostapi/Security/User/GetAll" ResponseType="JSON">
<DataService TableName="SecuHostUser" Type="OData" />
</DataBinding>
</ClientSettings>
</telerik:RadGrid>
Wep Api code
[HttpGet]
public List<SecuHostUser> GetAll(ODataQueryOptions<SecuHostUser> options)
{
UsersRep userRep = new UsersRep();
return userRep.GetAll();
}
although, I have put PageSize="5", the final result show all the data from the data base
This problem can be solved by returning a PageResult instead of a list.
[HttpGet]
public PageResult GetAll(ODataQueryOptions<SecuHostUser> options)
{
UsersRep userRep = new UsersRep();
//return userRep.GetAll();
var users = userRep.GetAll().AsQueryable();
var results = options.ApplyTo(users);
return new PageResult<SecuHostUser>(results as IEnumerable<SecuHostUser>,
Request.GetNextPageLink(), Request.GetInlineCount());
}

access controls inside edititemtemplate in radgrid from javascript

I have 2 textbox as shown in code below :
<telerik:GridTemplateColumn UniqueName="guarantyAmount" HeaderText="<%$Resources:Strings,amount %>">
<ItemTemplate>
<asp:Label Text='<%# Eval("WARRANTY_AMOUNT")%>' runat="server" id="warrantyAmountText">
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox runat="server" id="warrantyAmount" ClientEvents-OnValueChanging="warrantyAmount_ValueChanging"></telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="guarantyRealValue" HeaderText="<%$Resources:Strings,realValue %>">
<ItemTemplate>
<asp:Label Text='<%# Eval("REAL_VALUE")%>' runat="server" id="realValueText">
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox runat="server" id="realValue"></telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
what i want is to create " warrantyAmount_ValueChanging " js function that read input value from "warrantyAmount " textbox and put them in "realValue" ..
how can i achieve that ??
Please try with the below code snippet.
function warrantyAmount_ValueChanging(sender, args) {
var SenderId = sender.get_id();
var realValue = $telerik.findTextBox(SenderId.replace("warrantyAmount", "realValue"));
realValue.set_value(args.get_newValue());
}

Getting the key value to pass in another page from a LinkButton in a Telerik grid

I have a grid which has the CarrierID specified as the "DataKeyNames" which is also an invisible property in the grid.
I have a hyperlink column that when clicked should pass the value of the CarrierNetID (the keyvalue for that dataitem) into my codebehind so I can then pass it to another page to bring up a record for editing based on that key value.
I'm having trouble getting the attached error:
My markup is as follows: You can see that the lnkPLMN is the hyperlink. Everything is coming out on the grid just fine, I just can't seem to pass the value.
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" ShowStatusBar="true"
runat="server" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True"
AutoGenerateColumns="false" ClientSettings-Resizing-AllowColumnResize="true"
DataKeyNames="CarrierNetID" OnItemDataBound="RadGrid_ItemDataBound">
<MasterTableView PageSize="10" Width="100%">
<Columns>
<telerik:GridBoundColumn DataField="CarrierNetID" Visible="false" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Name" HeaderText="Carrier Name" UniqueName="Name" SortExpression="Name" ReadOnly="true" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Region" HeaderText="Region" UniqueName="Region" AllowFiltering="true" SortExpression="Region" ReadOnly="true" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Country" HeaderText="Country" UniqueName="Country" SortExpression="Country" ReadOnly="true" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="PLMN" UniqueName="PLMN">
<ItemTemplate>
<asp:HyperLink ID="lnkPLMN" runat="server" Target="_blank" ForeColor="Blue">
</asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="TechnologyTypeCode" HeaderText="Technology" UniqueName="TechnologyTypeCode" SortExpression="TechnologyTypeCode" ReadOnly="true" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SMSMORate" HeaderText="SSMSO Rate" UniqueName="SMSMORate" AllowFiltering="false" SortExpression="SMSMORate" ReadOnly="true" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:G}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SMSMTRate" HeaderText="SMSMT Rate" UniqueName="SMSMTRate" AllowFiltering="false" SortExpression="SMSMTRate" ReadOnly="true" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:G}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="DataRate" HeaderText="Data Rate" UniqueName="DataRate" AllowFiltering="false" SortExpression="DataRate" ReadOnly="true" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:G}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="MOCRate" HeaderText="MOC Rate" UniqueName="MOCRate" AllowFiltering="false" SortExpression="MOCRate" ReadOnly="true" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:G}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="MTCRate" HeaderText="MTC Rate" UniqueName="MTCRate" AllowFiltering="false" SortExpression="MTCRate" ReadOnly="true" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:G}"></telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="FlatRate" HeaderText="Flat Rate" UniqueName="FlatRate" SortExpression="FlatRate" ReadOnly="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"></telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn DataField="Discount" HeaderText="Discount" UniqueName="Discount" SortExpression="Discount" ReadOnly="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"></telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn DataField="ActiveFlag" HeaderText="Active" UniqueName="ActiveFlag" SortExpression="ActiveFlag" ReadOnly="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"></telerik:GridCheckBoxColumn>
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true">
</ClientSettings>
<PagerStyle Mode="NumericPages"></PagerStyle>
</telerik:RadGrid>
Here is my codebehind which gets the attached error on the following line:
HyperLink link = (HyperLink)item["PLMN"].Controls[0];
protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
HyperLink link = (HyperLink)item["PLMN"].Controls[0];
string value = item.GetDataKeyValue("CarrierNetID").ToString();
link.NavigateUrl = "~/CarrierLaunchStatusForm.aspx?addRecord=0&ID=" + value;
}
}
Can someone please help?
After placing the hyperlink in the markup (instead of the code behind), I'm getting the following compilation error:
Error 2 The GridHyperLinkColumn control with a two-way databinding to field PLMN must have an ID. C:\Projects\NPP\NPP\NPP\NPP\CarrierLaunchStatus.ascx 53
Error 3 Literal content ('</telerik:GridHyperLinkColumn>') is not allowed within a 'Telerik.Web.UI.GridColumnCollection'. C:\Projects\NPP\NPP\NPP\NPP\CarrierLaunchStatus.ascx 56
The Hyperlink column looks as follows:
<telerik:GridHyperLinkColumn UniqueName="PLMN" DataTextFormatString='<%# Bind("PLMN") %>'
DataTextField="PLMN" DataNavigateUrlFields="CarrierNetID" DataNavigateUrlFormatString="~/CarrierLaunchStatusForm.aspx?addRecord=0&ID={0}"
Target="_blank">
</telerik:GridHyperLinkColumn>
What am I missing here?
Unless you really need to modify data on the ItemDataBound event, You can just use the GridHyperLinkColumn:
<telerik:GridHyperLinkColumn DataNavigateUrlFields="CarrierNetID"
DataNavigateUrlFormatString="~/CarrierLaunchStatusForm.aspx?addRecord=0&ID={0}"
Target="_blank" Text="Your Link Text"></telerik:GridHyperLinkColumn>

Getting error while updating LINQDatasource

When I try to update a LINQ data source bound to a grid view, I get the following error:
Could not find a row that matches the given keys in the original values stored in ViewState. Ensure that the 'keys' dictionary contains unique key values that correspond to a row returned from the previous Select operation.
I have specified DataKeyNames in the grid view.
Here's the HTML:
<asp:GridView ID="TaskGridView" runat="server" AutoGenerateColumns="False"
DataKeyNames="taskid,statusid,taskdescription" DataSourceID="GridDataSource"
onrowcreated="TaskGridView_RowCreated">
<Columns>
<asp:TemplateField HeaderText="taskid" InsertVisible="False"
SortExpression="taskid">
<ItemTemplate>
<asp:Label ID="TaskId" runat="server" Text='<%# Bind("taskid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="taskdescription"
SortExpression="taskdescription">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("taskdescription") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="TaskDesc" runat="server" Text='<%# Bind("taskdescription") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="url" HeaderText="url" SortExpression="url" />
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:DropDownList runat="server" ID="ddStatus" DataSourceID="DropDownDataSource" DataValueField="statusid" SelectedValue="<%# Bind('Statusid') %>" DataTextField="statusdescription" ></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="GridDataSource" runat="server"
ContextTypeName="DailyTask.DailyTaskDBDataContext" TableName="tbl_tasks"
EnableUpdate="True">
</asp:LinqDataSource>
<asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click"
Text="Update" />
<asp:LinqDataSource ID="DropDownDataSource" runat="server"
ContextTypeName="DailyTask.DailyTaskDBDataContext" TableName="tbl_status">
</asp:LinqDataSource>
Here's the corresponding code:
protected void btnUpdate_Click(object sender, EventArgs e)
{
ListDictionary keyValues = new ListDictionary();
ListDictionary newValues = new ListDictionary();
ListDictionary oldValues = new ListDictionary();
try
{
keyValues.Add("taskid", ((Label)TaskGridView.Rows[0].FindControl("TaskId")).Text);
oldValues.Add("taskdescription", ((Label)TaskGridView.Rows[0].FindControl("TaskDesc")).Text);
newValues.Add("taskdescription", "New Taskk");
GridDataSource.Update(keyValues, newValues, oldValues);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
I got the problem it was in the code
I just have to use int.Parse() here because taskid is primary key
keyValues.Add("taskid", int.Parse(((Label)TaskGridView.Rows[0].FindControl("TaskId")).Text));

Resources