How to Pre-Select a DataGrid Row Radiobutton ?

S

savvy

I have used MetaBuilders.WebControls for including a radiobutton in a
datagrid. Its works fine with retreiving the checked radiobutton
datagrid row id. but i'm not able to preselect the row radiobutton
which matches with the database data. ok
I have a Datagrid which displays CV details created by a candidate. So
i want him to make only one of his CVs as a default one. Therefore i
included a radiobutton column which selects the particular row of the
datagrid and stores in it in the database with a Flag 1 or 0.
So, everytime i will be comparing the flag and if its 1 then i want the
radio button of that particular row to be checked. I tried alot but i'm
getting nowhere
Any help will be greatly appreciated
Thanks in Advance

I'm using this code
using MetaBuilders.WebControls;

objcmd = new SqlCommand("SelectCVdetails", objConn);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.Add("@js_id", Session["JSRegID"]);
objConn.Open();
objRdr = objcmd.ExecuteReader();
dgcvdetails.DataSource=objRdr;
dgcvdetails.DataBind();
objRdr.Close();
objConn.Close();
for (int i = 0; (i <= (dgcvdetails.Items.Count - 1)); i++)
{
if ((dgcvdetails.Items.Cells[6].ID == intcv_id.ToString()))
{
dgcvdetails.Items.BackColor = System.Drawing.Color.Blue;
HtmlInputRadioButton rsc =
((HtmlInputRadioButton)(dgcvdetails.Items.FindControl("RowSelectorColumnSelector")));
rsc.Checked = true;
break;
}
}
 
S

savvy

I got this problem solved. I'm giving the solution below if in case
anyone run into the same problem

.........

int intcv_id = Convert.ToInt16(objRdr["CV_ID"]);

.......

objcmd = new SqlCommand("SelectCVdetails", objConn);

objcmd.CommandType = CommandType.StoredProcedure;

objcmd.Parameters.Add("@js_id", Session["JSRegID"]);

objConn.Open();

objRdr = objcmd.ExecuteReader();

dgcvdetails.DataSource=objRdr;

dgcvdetails.DataBind();

objRdr.Close();

objConn.Close();

foreach(DataGridItem DgItem in dgcvdetails.Items)

{

int intdgcv_id =
Convert.ToInt32(dgcvdetails.DataKeys[DgItem.ItemIndex]);

if(intdgcv_id==intcv_id)

{

dgcvdetails.Items[DgItem.ItemIndex].BackColor =
System.Drawing.Color.GhostWhite;

HtmlInputRadioButton rsc =
((HtmlInputRadioButton)(dgcvdetails.Items[DgItem.ItemIndex].FindControl("RowSelectorColumnSelector")));

rsc.Checked = true;

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top