edit datagrid with dropdownlist

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

I have a template column with a drop down list which should pass the
value selected by the user to a function which will return a value of
its place in the list...I keep getting the error 'denotes a 'property'
where a 'method' was expected'. Any ideas?

<asp:TemplateColumn HeaderText="CallType">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "CallType") %>
</ItemTemplate>

<EditItemTemplate>
<asp:DropDownList runat="server" id="lstCallTypes"
DataValueField="CallType"
DataTextField="CallType"
DataSource='<%# GetCallTypes() %>'
SelectedIndex='<%#
GetSelIndex(Container.DataItem("CallType")) %>'
/>
</EditItemTemplate>

</asp:TemplateColumn>


private int GetSelIndex(string strCallType)
{
int intLoop;
//Loop through each row in the DataSet
DataTable dt = ddlDataSet.Tables["CallTypes"];

for (intLoop = 0; intLoop >= dt.Rows.Count-1; intLoop ++)
{
if (Int32.Parse(strCallType) =
Int32.Parse((string)dt.Rows[intLoop]["CallType"]))
{
return intLoop;
}
}
}

Thanks,

Mike
 
Hi

Please look into the following URL:
http://www.4guysfromrolla.com/webtech/050801-1.shtml

Ravikanth[MVP]

-----Original Message-----
I have a template column with a drop down list which should pass the
value selected by the user to a function which will return a value of
its place in the list...I keep getting the error 'denotes a 'property'
where a 'method' was expected'. Any ideas?

<asp:TemplateColumn HeaderText="CallType">
<%#
DataBinder.Eval(Container.DataItem, "CallType") %><asp:DropDownList
runat="server" id="lstCallTypes"
DataValueField="CallType"

SelectedIndex='<%#
GetSelIndex(Container.DataItem("CallType")) %>'
/>
private int GetSelIndex(string strCallType)
{
int intLoop;
//Loop through each row in the DataSet
DataTable dt = ddlDataSet.Tables["CallTypes"];

for (intLoop = 0; intLoop >= dt.Rows.Count-1; intLoop ++)
{
if (Int32.Parse(strCallType) =
Int32.Parse((string)dt.Rows[intLoop]["CallType"]))
{
return intLoop;
}
}
}

Thanks,

Mike




.
 
Back
Top