edit datagrid with dropdownlist


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
 
Ad

Advertisements

R

Ravikanth[MVP]

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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top