Thursday, February 9, 2012

Set Tab Indexes to Gridview Controls Programmatically in C#

private void SetTabIndexes_SutaRates()
{
short currentTabIndex = currentTabIndexSUTA;

foreach (GridViewRow gvr in grdCurrentCost.Rows)
{
TextBox inputField1 = (TextBox)gvr.FindControl("txtCurrentSutaRate");
inputField1.TabIndex = ++currentTabIndex;

DropDownList dropDown1 = (DropDownList)gvr.FindControl("ddlCompanyLst");
dropDown1.TabIndex = ++currentTabIndex;

TextBox inputField2 = (TextBox)gvr.FindControl("txtSutaBillRate");
inputField2.TabIndex = ++currentTabIndex;
}


}

Function Call in OnDataBound Event of Gridview

protected void grdCurrentCost_DataBound(object sender, EventArgs e)
{
SetTabIndexes_SutaRates();
}

No comments:

Post a Comment