Hello Guys,
I am new to Telerik Radgrid. I need your help. I have a radgrid with ItemTemplate and TextBox in template. Ive a selection window which pops up on TextBox inside grid is clicked and upon selecting some data value should set in that particular TextBox.
<Columns><telerik:GridTemplateColumn DataField="CA_ACC_CODE" HeaderText="Account Code" ItemStyle-BorderColor="#d6d6d6" SortExpression="CA_ACC_CODE" UniqueName="CA_ACC_CODE"><ItemTemplate><asp:TextBox ID="txtAccountCode" OnClick="return showPopUp(this)" Text='<%# Bind("CA_ACC_CODE")%>' runat="server" Width="120px" Skin="Office2007"></asp:TextBox></ItemTemplate> <ItemStyle BorderColor="#D6D6D6" /> </telerik:GridTemplateColumn></Columns>
The problem I am facing how to iterate and set value in particular textbox. Currently the textbox value is setting in first row of grid only in ItemDataBound event regardless of any row where I click the textbox.
protected void gv_BO_ItemDataBound(object sender, GridItemEventArgs e){ try { string Selectd_row = (string)(Session["coa_selectd_row"]); if (Selectd_row == null || Selectd_row == "") { Selectd_row = "0"; } if (e.Item.RowIndex == int.Parse(Selectd_row)) { if (e.Item is GridEditFormItem) { GridEditFormItem item = (GridEditFormItem)e.Item; string cc_code = (string)(Session["cc_code"]); string cc_title = (string)(Session["cc_title"]); string ca_code = (string)(Session["coa_code"]); string ca_title = (string)(Session["coa_title"]); TextBox txtCostCentre = (TextBox)item["CC_COSTCNTR_CODE"].FindControl("txtCostCentre"); TextBox txtCCDesc = (TextBox)item["CC_DESC"].FindControl("txtCCDesc"); TextBox txtAccountCode = (TextBox)item["CA_ACC_CODE"].FindControl("txtAccountCode"); TextBox txtAccountTitle = (TextBox)item["CA_TITLE"].FindControl("txtAccountTitle"); txtCostCentre.Text = cc_code; txtCCDesc.Text = cc_title; txtAccountCode.Text = ca_code; txtAccountTitle.Text = ca_title; } } }catch (Exception ex) { } }