1 Replies - 4482 Views - Last Post: 28 June 2010 - 06:04 AM Rate Topic: -----

#1 xoops  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 06-August 09

how to set variable in asp:sqldatasource select command in asp.net c#

Posted 28 June 2010 - 05:53 AM

hello all,
i want to ask how to i set variable in asp:sqldatasource in sqlcommand in asp.net c#....
This is my code

asp.net
     <dx:ASPxListBox ID="lsAssignToko" runat="server" DataSourceID="SqlDataSource6" 
                                            TextField="NAMA" ValueField="ID" AutoPostBack="true" 
                                            EnableCallbackMode="True" SelectionMode="CheckColumn" 
                                            onselectedIndexChanged="lsAssignToko_SelectedIndexChanged">
                                            <Columns>
                                                <dx:ListBoxColumn FieldName="ID"/>
                                                <dx:ListBoxColumn FieldName="NAMA" />
                                            </Columns>
                                        </dx:ASPxListBox>
                                      
                                        <asp:SqlDataSource ID="SqlDataSource6" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:Ora2010 %>" 
                                            ProviderName="<%$ ConnectionStrings:Ora2010.ProviderName %>" 
                                            
                                            
                                            
                                            SelectCommand="SELECT ID, NAMA FROM REF_TOKO WHERE ID IN ( :inTOKO ) ORDER BY NAMA">
                                          
                                            <SelectParameters>
                                                <asp:SessionParameter Name="inTOKO" SessionField="inTOKO" Size="200" Type="String" />
                                            </SelectParameters>
                                          
                                        </asp:SqlDataSource>




c#
string dummy = "";
        string data = "";
        string inTK = "";
        string inTOKO = "";
        //string inTOKO1 = "";
        int pot;

        for (int i = lsToko.SelectedItems.Count - 1; i >= 0; i--)
        {
            string tok = lsToko.SelectedItem.Text.ToString();
            data = lsToko.SelectedItem.Value.ToString();
            dummy = dummy + "" + data + ",";
            int index = lsToko.SelectedItem.Index;
            lsToko.Items.RemoveAt(index);

        }

        if (lsToko.SelectedItems.Count <= 1)
        {
            inTK = dummy.Length.ToString();
            pot = int.Parse(dummy.Length.ToString()) - 1;
            inTOKO = dummy.Substring(0, pot);
        }

       
        Session["inTOKO"] = inTOKO;



the problem is where in my variable inTOKO consist of couple of value...
Example
while variable inTOKO = one value success but while value inTOKO = two value error
inTOKO = 1101111 => success
inTOKO = 1101111,1211321 => not success

i stuck in here. Please tell me how i fix it. Thanks.....

This post has been edited by xoops: 28 June 2010 - 05:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how to set variable in asp:sqldatasource select command in asp.net c#

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: how to set variable in asp:sqldatasource select command in asp.net c#

Posted 28 June 2010 - 06:04 AM

moved to ASP.Net
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1