Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
me have 5 columns and one of them is Business id when i bind data to control all bind but drowdown list ones are not bind.can any one give any suggession or simple idea.i have try on many ways but not complete my task .and same situation with chekbox also want help for chek box
my code are below

C#
<script>
       function EditRecord(Aid,Aaid,Bid,TAmount,APaid,ABalance,Tdate,Fmonth,Fyear,Gobserverd,Rmark) {
           $('[id$="hfAccount"]').val(Aid);
           $('[id$="AccountId"]').val(Aaid);
           //this is dropdown list...//
           $('[id$="ddlBusiness"]').val(Bid);
           $('[id$="txtTotalAmount"]').val(TAmount);
           $('[id$="txtAmountPaid"]').val(APaid);
           $('[id$="txtAmountBalance"]').val(ABalance);
           $('[id$="txtTransactionDate"]').val(Tdate);
           $('[id$="txtForMonth"]').val(Fmonth);
           $('[id$="txtForYear"]').val(Fyear);
           $('[id$="txtGestureObserved"]').val(Gobserverd);
           $('[id$="txtRemarks"]').val(Rmark);
           $('[id$="btnUpdate"]').removeAttr("disabled");
          }

   </script

XML
<asp:TemplateField  HeaderText="Edit">
               <ItemTemplate>
                   <a style="cursor:pointer" onclick="EditRecord('<%#Eval("AccountId")%>','<%#Eval("AccountId")%>','<%#Eval("BusinessTitle")%>','<%#Eval("TotalAmount")%>','<%#Eval("AmountPaid")%>','<%#Eval("AmountBalance")%>','<%#  Convert.ToDateTime(Eval("TransactionDate")).ToShortDateString()%>','<%#Eval("ForMonth")%>','<%#Eval("ForYear")%>','<%#Eval("GestureObserved")%>','<%#Eval("Remarks")%>')"><img id="imgEdit" src="Images/edit2.ico" alt="Edit"/>
               </ItemTemplate>
           </asp:TemplateField>

when i click this button all data are bind with controls except ddlBusiness
Posted
Updated 6-May-14 1:43am
v2
Comments
DamithSL 6-May-14 7:28am    
explain issue with code sample, include your aspx and code behind related codes.
Mian Sahib Jan 6-May-14 7:38am    
ok
Where is the DropDownList in the Markup?
Mian Sahib Jan 6-May-14 8:59am    
'<%#Eval("BusinessTitle")%>'
Okay, now put a debugger inside the function EditRecord and see if the BusinessTitle parameter is coming correctly or not.

C#
 protected void grdReview_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddlId= (DropDownList)e.Row.FindControl("ddl");
//Here write your code to fill dropdownlist
                ddlID.DataSource=ds;
                ddlID.DataBound();

            }
   } 
 
Share this answer
 
Comments
Mian Sahib Jan 6-May-14 7:48am    
this is good but i want to click the button or icon in gridview and all the data are bound me post my code that bind all data with control but problem with dropdown list which not bind
Mian Sahib Jan 6-May-14 14:42pm    
thanks to all who share their knowlege and suggesition with us.my problem are solved
try this..

Button_OnClick()
{

Button btn=(Button)sender;
GridViewRow r=(GridviewRow)btn.parent.parent;
DropDownList ddlId= (DropDownList)r.FindControl("ddl");
//Here write your code to fill dropdownlist
ddlID.DataSource=ds;
ddlID.DataBound();
}
 
Share this answer
 

Below is the revised version of the OP's reply...


"I only changed the database view/DataSource.

In the Edit Button click, I send the id of the control and the Grid showing the businessTitle.
So, when I click the edit button, it sends the id of DropDownList and the DropDownList have been already filled from DataSet. When the DropDownList id goes, before that the businessTitle are already populated on that."

My Conclusion


So, basically the issue was with the popuation of the DropDownList Data, which got fixed by doing modification to the DataSource.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900