I know my question is really easy but i can’t get its solution since last three hours.
I have created a gridview which has three columns PeriodID,PeriodName and Checkbox.
now when i go through for each loop for this grid,i want to get periodid value of each row in this gridview..
for this i have writen code like this.
foreach (GridViewRow row in gvdchk.Rows)
{
int i = row.RowIndex;
var cb = (HtmlInputCheckBox)row.FindControl("chkPaid");
var Periodid = gvdchk.Rows[i].FindControl("PeriodID");
//string su = Periodid.ToString();
// Guid PeriodID = Guid.Parse(su);
// Guid guid = new Guid(Periodid);
//var PeriodID = row.FindControl("PeriodID");
//Guid PeriodId = (Guid) PeriodID;
//Guid PeriodId = (Guid)(gvdchk.Rows[row.RowIndex].FindControl("datemonth2"));
// int order = m.bussinesCollection.BussinesPeriod.GetOrder(PeriodID);
if (cb != null && cb.Checked)
{
}
}
When I debug my code,I found that var Periodid gets the correct value of the period id but I want it as Guid.
Can anyone help in this..?
The following code that you have in your post
Guid guid = new Guid(Periodid);will work fine to convert the string to GUID.
You can also check what is the datatype for the Periodid that you get in the line no. 5 of your code.