Search Results

Search found 5 results on 1 pages for 'lodun'.

Page 1/1 | 1 

  • autopostback problem listbox asp.net

    - by lodun
    I want to add posts(question) like i do that on yahoo answers.When i choose item in "kategorije" control,items can't be loaded in "SUB_kategorije" control. Image My new ascx.cs: 1. protected void Page_Load(object sender, EventArgs e) 2. { 3. 4. 5. if (!Page.IsPostBack) 6. { 7. 8. SqlDataSource ds = new SqlDataSource(); 9. ds.ConnectionString = conn; 10. ds.SelectCommand = "SELECT [ID], [Kategorije] FROM [kategorije] "; 11. kategorije.DataSource = ds; 12. kategorije.DataTextField = "Kategorije"; 13. kategorije.DataValueField = "ID"; 14. kategorije.DataBind(); 15. kategorije.SelectedIndex = 1; 16. 17. SqlDataSource dk = new SqlDataSource(); 18. dk.ConnectionString = conn; 19. dk.SelectCommand = "SELECT * from pod_kategorije WHERE kat_id = " + kategorije.SelectedItem.Value; 20. SUB_kategorije.DataSource = dk; 21. SUB_kategorije.DataTextField = "pkategorija"; 22. SUB_kategorije.DataValueField = "ID"; 23. SUB_kategorije.DataBind(); 24. 25. 26. } 27. 28. 29. 30. 31. } 32. protected void kategorije_SelectedIndexChanged(object sender, EventArgs e) 33. { 34. 35. 36. SqlDataSource dk = new SqlDataSource(); 37. dk.ConnectionString = conn; 38. dk.SelectCommand = "SELECT * from pod_kategorije WHERE [kat_id] = " + kategorije.SelectedItem.Value; 39. SUB_kategorije.DataSource = dk; 40. SUB_kategorije.DataTextField = "pkategorija"; 41. SUB_kategorije.DataValueField = "ID"; 42. SUB_kategorije.DataBind(); 43. 44. 45. } and .ascx: 1. <asp:ListBox ID="kategorije" runat="server" Height="380px" CssClass="kat" AutoPostBack="true" 2. 3. onselectedindexchanged="kategorije_SelectedIndexChanged"></asp:ListBox> 4. 5. <asp:Button ID="Button1" CssClass="posalji" runat="server" Text="click" 6. onclick="Button1_Click" /> 7. 8. 9. 10. <asp:UpdatePanel ID="UpdatePanel10" runat="server"> 11. <ContentTemplate> <asp:ListBox ID="SUB_kategorije" CssClass="pod" Height="150px" runat="server"></asp:ListBox></ContentTemplate> 12. <Triggers> 13. <asp:AsyncPostBackTrigger ControlID="kategorije" EventName="SelectedIndexChanged" /> 14. 15. </Triggers> 16. 17. </asp:UpdatePanel>

    Read the article

  • asp.net listbox

    - by lodun
    Why this code don't work,when i want run this code vwd 2008 express show me this error: Object reference not set to an instance of an object. Line 73: kom.Parameters.Add("@subcategories", SqlDbType.Text).Value = s_categoreis.SelectedItem.ToString(); This is my ascx file: <asp:ListBox ID="categories" runat="server" Height="380px" CssClass="kat" AutoPostBack="true" DataSourceID="SqlDataSource1" DataTextField="Categories" DataValueField="ID" onselectedindexchanged="kategorije_SelectedIndexChanged"></asp:ListBox> <asp:Button ID="Button1" CssClass="my" runat="server" Text="click" onclick="Button1_Click" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ListBox ID="s_categoreis" CssClass="pod" Height="150px" Enabled="true" runat="server"></asp:ListBox></ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="categories" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:estudent_piooConnectionString %>" SelectCommand="SELECT [ID], [Categories] FROM [categories]"> </asp:SqlDataSource> and this is my ascx.cs: SqlConnection veza; SqlCommand kom = new SqlCommand(); SqlParameter par1 = new SqlParameter(); SqlParameter par2 = new SqlParameter(); SqlParameter par3 = new SqlParameter(); SqlParameter par4 = new SqlParameter(); SqlParameter par5 = new SqlParameter(); SqlParameter par6 = new SqlParameter(); SqlParameter par7 = new SqlParameter(); SqlParameter par8 = new SqlParameter(); SqlParameter par9 = new SqlParameter(); protected void Page_Load(object sender, EventArgs e) { Listapod_kategorije(1); } protected void kategorije_SelectedIndexChanged(object sender, EventArgs e) { Listapod_kategorije(Convert.ToInt32(kategorije.SelectedValue)); } private void Listapod_kategorije(int broj) { SqlDataSource ds = new SqlDataSource(); ds.ConnectionString = ConfigurationManager.ConnectionStrings["estudent_piooConnectionString"].ConnectionString; ds.SelectCommand = "Select * from pod_kategorije where kat_id=" + broj; pod_kategorije.DataSource = ds; pod_kategorije.DataTextField = "pkategorija"; pod_kategorije.DataValueField = "ID"; pod_kategorije.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { Guid jk = new Guid(); object datum = DateTime.Now; veza = new SqlConnection(@"server=85.94.76.170\PADME; database=estudent_pioo;uid=pioo;pwd=1234567"); Random broj = new Random(); int b_kor = broj.Next(1, 1000); kom.Parameters.Add("@text", SqlDbType.Text).Value = str; kom.Parameters.Add("@user", SqlDbType.UniqueIdentifier).Value = jk; kom.Parameters.Add("@date", SqlDbType.DateTime).Value = datum; kom.Parameters.Add("@visits", SqlDbType.Int).Value = 0; kom.Parameters.Add("@answers", SqlDbType.Int).Value = 0; kom.Parameters.Add("@username", SqlDbType.Text).Value = "unknown_" + b_kor.ToString(); ; kom.Parameters.Add("@categories", SqlDbType.Text).Value = categories.SelectedItem.ToString(); kom.Parameters.Add("@sub_categories", SqlDbType.Text).Value = s_categoreis.SelectedItem.ToString(); veza.Open(); kom.ExecuteNonQuery(); veza.Close(); Response.Redirect("default.aspx");

    Read the article

  • auto complete asp.net

    - by lodun
    Why my autocomplete ajax script does not work: This is my WebService.cs: using System; using System.Data; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.ComponentModel; using System.Data.SqlClient; using System.Collections.Generic; using System.Configuration; using System.Web.Script.Services; [ScriptService] [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. public class WebService : System.Web.Services.WebService { public WebService () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string[] GetCountryInfo(string prefixText, int count) { string sql = "Select * from questions Where username like @prefixText"; SqlDataAdapter da = new SqlDataAdapter(sql,"estudent_piooConnectionString"); da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%"; DataTable dt = new DataTable(); da.Fill(dt); string[] items = new string[dt.Rows.Count]; int i = 1; foreach (DataRow dr in dt.Rows) { items.SetValue(dr["username"].ToString(),i); i++; } return items; } } my css: /*AutoComplete flyout */ .autocomplete_completionListElement { margin : 0px!important; background-color : inherit; color : windowtext; border : buttonshadow; border-width : 1px; border-style : solid; cursor : 'default'; overflow : auto; height : 200px; text-align : left; list-style-type : none;padding:0px; } /* AutoComplete highlighted item */ .autocomplete_highlightedListItem { background-color: #ffff99; color: black; padding: 1px; } /* AutoComplete item */ .autocomplete_listItem { background-color : window; color : windowtext; padding : 1px; } and textbox: <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem" CompletionSetCount="20" CompletionInterval="1000" DelimiterCharacters=";,:" CompletionListHighlightedItemCssClass="autocomplete_highlightedList MinimumPrefixLength="1" ServiceMethod="GetCountryInfo" ShowOnlyCurrentWordInCompletionListItem="true" TargetControlID="TextBox2" ServicePath="WebService.asmx" runat="server"></cc1:AutoCompleteExtender>

    Read the article

  • list box asp.net selected problem

    - by lodun
    .When i choose item from "kategorije" new items loads to me in SUB_kategorije, but when i choose item from SUB_kategorije and when i click on button it shows me this error: Object reference not set to an instance of an object. Line 101: kom.Parameters.Add("@podkategorija", SqlDbType.Text).Value = SUB_kategorije.SelectedItem.ToString(); This is my source... dod_pit.ascx dod_pit.ascx.cs

    Read the article

1