How to Render DropDownListbox in DVWP Edit Template.

I was Working with DVWP and Sql Server to display,Insert and Update data.When i was working i had to render Dropdownlist which will bound to sql table in Edit template of DVWP.
  • GO to Common Dataview Task and in Dataview Preview select Edit template.
  • GO to Split View of DVWP and in Design View Select field which you want to render as  Dropdownlist.
  • In Code View Comment the code which render TextBox as shown
     <!--<asp:Textbox runat="server" id="ff3{$Pos}" text="{@JM_CERTIFICATION_DESC}" __designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'Text','TextChanged','JM_CERTIFICATION_ID',ddwrt:EscapeDelims(string(@JM_CERTIFICATION_ID)),'@JM_CERTIFICATION_DESC')}" />--> 

     

  • Now Create Datasource for Sql Table from which you want to display data in Dropdownlist as shown
    <asp:SqlDataSource id="CertiDS" runat="server" __designer:commandsync="true" ProviderName="System.Data.SqlClient" ConnectionString="Data Source=" ";User ID=" ";Password=" ";Initial Catalog=" "; "SelectCommand="SELECT JM_CERTIFICATION_TYPE_ID,JM_CERTIFICATION_DESC FROM JM_CERTIFICATION_TYPE_T " />

  • Now Drag and Drop SharePoint DVDropDownList from Toolbox.
  • Make sure you have same id from Textbox control above and Make change to some of its Property as shown
    <SharePoint:DVDropDownList ID="ff3{$Pos}" runat="server" DataSourceID="CertiDS" DataTextField="JM_CERTIFICATION_DESC" DataValueField="JM_CERTIFICATION_TYPE_ID" selectedvalue="{@JM_CERTIFICATION_TYPE_ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'SelectedValue','SelectedIndexChanged','JM_CERTIFICATION_ID',ddwrt:EscapeDelims(string(@JM_CERTIFICATION_ID)),'@JM_CERTIFICATION_TYPE_ID')}" >

  • If Everything is correct it will work fine.

Thanks
Ronak
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s