Author |
Topic |
jhermiz
3564 Posts |
Posted - 2004-11-19 : 14:25:05
|
Been searching google and every frigging MS site and most of these methods are incredibly weird or ridiculious.All I want to do is ahve a drop down list box on my datagrid.Probably only when they click the edit button. I tried filling up my combo box but I keep getting reference errors saying the box has "nothing".Anyone have any samples on simply how to create a combo box on a datagrid ?Thanks,Jon |
|
robvolk
Most Valuable Yak
15732 Posts |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 14:31:06
|
Err I cant change that because of paging sorting and a whole slew of other things.I know there is got to be a way of doing it...Jon |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-19 : 14:38:03
|
You can spend money on a custom datagrid control, but the stock DataGrid won't do it.Hit Google for "DataGrid" and so some research, and read that article again. Also read this one:http://aspnet.4guysfromrolla.com/articles/052103-1.aspxI'd suggest reading every article on 4Guys about DataGrids, and whatever Scott says about them is gospel. If he says it can't be done with a DataGrid, then it can't. He has an entire series of articles (14 or more parts) on DataGrids, read them all. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 14:53:10
|
I know i saw this article but it is rather tedious thats why I was hoping someone provided a more realistic solution.Jon |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-19 : 14:53:44
|
What does "realistic" mean? |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 14:55:16
|
I mean look at the code, I dont see a single reference to a drop down list.The code is not using any stored procedures and it has a lot of hardcoded SQL. I want to be able to use a drop down list. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-19 : 15:13:56
|
Jon, did you actually read this article I posted?http://www.4guysfromrolla.com/webtech/050801-1.shtmlquote: <EditItemTemplate> <asp:DropDownList id=cmbStatuses runat="server" datavaluefield="StatusCode" datatextfield="Name" DataSource="<%#DropDownDataView%>"> </asp:DropDownList> </EditItemTemplate>
That's sitting smack in the middle of the 2nd code block on the 1st page. There's also a 2nd page, which contains the code that calls the stored procedure. |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:15:33
|
I know ive read it I am looking at it right now. How about you try this...just like I did. First look at the second page of the code, Temp Info, you you think I cannot see the code? I've tried what they have and to be honest that code is NOT working.I know how to RTFM :). |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:24:18
|
Tell me whats wrong complete copy of that article returns errors: Protected Sub PopList() Dim dataAdapter As SqlDataAdapter ' sqldatasetcommand Dim DS As New DataSet Dim NewConnection As SqlConnection = _ New SqlConnection(ConfigurationSettings.AppSettings("strConn")) dataAdapter = New SqlDataAdapter("select_functional_groups_by_client_id", NewConnection) dataAdapter.SelectCommand.CommandType = _ CommandType.StoredProcedure dataAdapter.Fill(DS, "TempInfo") 'filldataset what the hell is tempinfo??? TempDataView = DS.Tables("TempInfo") 'error here! End Sub Public Sub dgRespPerson_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgRespPerson.EditCommand PopList() Me.dgRespPerson.EditItemIndex = e.Item.ItemIndex BindGrid(1) End Sub I also declared the dataview:Protected TempDataView As DataView = New DataView Also the HTML:<asp:TemplateColumn SortExpression="1" HeaderText="Functional Group"> <ItemStyle Wrap="False" Width="20%"></ItemStyle> <ItemTemplate> <asp:Label id=Label1 runat="server" Text='<%#Container.DataItem("FunctionalGroup") %>'> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList id="ddlChangeFuncGroup" runat="server" DataValueField="FunctionalGroupID" DataTextField="FunctionalGroup" DataSource="<%#DropDownDataView%>"></asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> So whats the dilly ?Error I get is:\\Jakah-iis-2\ims\ResponsiblePerson.aspx.vb(388): Value of type 'System.Data.DataTable' cannot be converted to 'System.Data.DataView'. |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-11-19 : 15:25:37
|
have you read the part 2 of the article? Go with the flow & have fun! Else fight the flow |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:26:12
|
Yes I have. |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:26:43
|
I'm not trying to be a dick here, but the way you guys talk almost makes you think that the world is full of idiots. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-19 : 15:28:33
|
Well, where did the DataTable come from? There is no DataTable in the article code. |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:29:38
|
Wow my point exactly, boy!!! |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-11-19 : 15:37:23
|
it should be:TempDataView = DS.Tables("TempInfo").DefaultView that's the bug in their codeGo with the flow & have fun! Else fight the flow |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:41:13
|
o wow wait a minute, thats not possible...rob said these guys are the gospel ;)I will try it out. |
 |
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-11-19 : 15:42:18
|
Your also gonna need to bind the DDL to TempDataView not DropDownDataView.PS. my thought on typos is they make you look at, and think about, whats going on instead of being a cut and paste coder :) |
 |
|
jhermiz
3564 Posts |
Posted - 2004-11-19 : 15:44:05
|
Ya we changed that, another bug this is just uncalled for...this cant be!!!!the world is coming to an end!!! These guys wrote this article on rolla and its choke full of bugs. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-19 : 15:46:10
|
Hey Jon, if you want help, lose the attitude. No one here is required to do your job for you.This is not the first time people have gone out of their way to help you and you've done very little or nothing to make it worth their time. If you want to pay us to help then putting up with some bullshit would be fine, but you're not paying us. |
 |
|
Next Page
|