asp.net - set the value of sql data source parameter -


i filtering data of sql data source setting where clause parameter in formatting [@a] , in event of combo box, set value parameter, previous sql data source gridview

sqldatasource2.selectparameters.clear(); sqldatasource2.selectparameters["@a"].defaultvalue = cid.tostring(); sqldatasource2.databind(); 

i need pass value where parameter.

i choose filtering parsed on non choice ( not form or control or profile or session ...)

this way gives me error. there way give value parameter [@a]?

try following:

aspx:

<asp:sqldatasource id="sqldatasource1" runat="server" datasourcemode="dataset"                     connectionstring="<%$connectionstrings:myconnectionstring %>"                     selectcommandtype="text"                    selectcommand = "select * table a=@a"                      cancelselectonnullparameter="false">          <selectparameters>             <asp:querystringparameter name="a" querystringfield="a"                             dbtype="string" convertemptystringtonull="true" />               </selectparameters> </asp:sqldatasource>  

c# code-behind:

change @a a:

sqldatasource2.selectparameters.clear(); sqldatasource2.selectparameters["a"].defaultvalue = cid.tostring(); sqldatasource2.databind(); 

if @a first parameter can set using index 0:

sqldatasource2.selectparameters.clear(); sqldatasource2.selectparameters[0].defaultvalue = cid.tostring(); sqldatasource2.databind(); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -