A lot of days I'm searching...
I have got a sharepoint list with 2 single line text field : Title and Level
I use visual studio to create an application page to replace de default form to add an item into this list because I want to have a dropdown list to put the value (not an id) of the Level field.
So I have a aspx page with like this :
<tr>
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
<nobr>Titre : <span class="ms-formvalidation"> *</span></nobr>
</H3>
</td>
<td class="ms-formbody" valign="top">
<SharePoint:FormField runat="server" ID="FormField1" ControlMode="New" FieldName="Title" />
</td>
</tr>
<tr>
<td width="190px" valign="top" class="ms-formlabel">
<h3 class="ms-standardheader">
<nobr>Level : <span class="ms-formvalidation"> *</span>
</nobr>
</h3>
</td>
<td width="400px" valign="top" class="ms-formbody">
<SharePoint:DVDropDownList runat="server" ID="drop1" ControlMode="New" FieldName="Level">
</SharePoint:DVDropDownList>
<SharePoint:FieldDescription runat="server" ID="FieldDescription1" ControlMode="New" />
</td>
</tr>
and the cs file with this to populate my dropdown list with values :
public partial class NewActiviteLevelForm : Microsoft.SharePoint.WebPartPages.WebPartPage
{
string siteUrl = SPContext.Current.Web.Url;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
//SPList list = web.Lists["List_Level"];
SPList list = web.Lists.TryGetList("List_Level");
if (list != null)
{
drop1.DataSource = list.Items;
drop1.DataValueField = "Title";
drop1.DataTextField = "Title";
drop1.DataBind();
}
else
{
//erreur sur le nom de la liste
}
}
}
}
}
My problem is that when I click the save button the title field work fine but the selected value for Level is not saving.
How can I fix this?
Thanks for your help.
0 commentaires:
Enregistrer un commentaire