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>
<aspropDownList
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
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>
<aspropDownList
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