DropDownList in DataGrid - Problem


W

wolfgang wagner

Hi all!

Im having a big problem including a DropDownList in my DataGrid.
After searchin round some Sites i thought i can get this thing working.
Here's my Code:

<asp:TemplateColumn HeaderText="Rechnertyp">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ht_rtyp_ref") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList
ID="Dropdownlist1" Runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="DropDown_SelectedIndexChanged"
DataSource="<%# readHelperTable() %>" DataTextField='<%#
DataBinder.Eval(Container.DataItem, "htrtyp_name_str") %>'
DataValueField="htrtyp_ref"/>
</EditItemTemplate>
</asp:TemplateColumn>

And here is the code behind:

protected DataTable readHelperTable()
{
DataSet ds = new DataSet();
try
{
string query = "SELECT * FROM htrtyp";
SqlDataAdapter SqlDa = new SqlDataAdapter(query,
this.strDbConn);
SqlDa.Fill(ds, "rechnerTyp");
}
catch (Exception e)
{
this.tbLogdata.Text += "readhelpertable " + e.Message;
}
return ds.Tables["rechnerTyp"];
}


I do hava a Problem to set the DataTextField and the DataValueField
cause i get an Error DataBinder.Eval: System.Data.DataRowView contains
no Attribute named 'htrtyp_name_str'. (sorry for my bad english but i
translated this errormessage from the german VisualStudio.Net)

I hope someone i able to help me.
Thx for your help in advance.

greets
wolfgang
 
Ad

Advertisements

Ad

Advertisements

W

wolfgang wagner

hi tim!

Tim::.. said:
Everything you need to know about datagrids

http://aspnet.4guysfromrolla.com/

Have fun...

:

reading the relevant articels on the site made me sure, that my code is
correct. but why am i getting this error

DataBinder.Eval: System.Data.DataRowView contains no Attribute named
'htrtyp_name_str'.

?????


greets
wolfgang
Hi all!

Im having a big problem including a DropDownList in my DataGrid.
After searchin round some Sites i thought i can get this thing working.
Here's my Code:

<asp:TemplateColumn HeaderText="Rechnertyp">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ht_rtyp_ref") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList
ID="Dropdownlist1" Runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="DropDown_SelectedIndexChanged"
DataSource="<%# readHelperTable() %>" DataTextField='<%#
DataBinder.Eval(Container.DataItem, "htrtyp_name_str") %>'
DataValueField="htrtyp_ref"/>
</EditItemTemplate>
</asp:TemplateColumn>

And here is the code behind:

protected DataTable readHelperTable()
{
DataSet ds = new DataSet();
try
{
string query = "SELECT * FROM htrtyp";
SqlDataAdapter SqlDa = new SqlDataAdapter(query,
this.strDbConn);
SqlDa.Fill(ds, "rechnerTyp");
}
catch (Exception e)
{
this.tbLogdata.Text += "readhelpertable " + e.Message;
}
return ds.Tables["rechnerTyp"];
}


I do hava a Problem to set the DataTextField and the DataValueField
cause i get an Error DataBinder.Eval: System.Data.DataRowView contains
no Attribute named 'htrtyp_name_str'. (sorry for my bad english but i
translated this errormessage from the german VisualStudio.Net)

I hope someone i able to help me.
Thx for your help in advance.

greets
wolfgang
 

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