asp.net - Problem with GridViewControl -


<asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <div>     <asp:gridview id="gridview1" runat="server" height="464px" width="743px"          autogeneratecolumns="false" emptydatatext="no rows selected"          datasourceid="answered"           style="z-index: 1; left: 327px; top: 334px; position: absolute; height: 464px; width: 743px">         <columns>             <asp:boundfield datafield="threadtitle" headertext="threadtitle"                  sortexpression="threadtitle" />         </columns>     </asp:gridview>     <asp:sqldatasource id="answered" runat="server"          connectionstring="<%$ connectionstrings:cp_allquestionsanswered %>" selectcommand="select threadtitle threads t inner join users u on  t.usersid=u.usersid t.usersid=@userid">         <selectparameters>             <asp:parameter name="userid" />         </selectparameters>     </asp:sqldatasource>   </div> </asp:content> 

code file:

protected void page_load(object sender, eventargs e) {     membershipuser currentuser = membership.getuser();     guid userid = (guid)currentuser.provideruserkey;     answered.selectparameters.add("userid", userid.tostring().trim()); } 

when modify grid's datasource, write query , test specific grid , gives me expected results. when run grid view, "empty rows". why that?!?

my guess this: in page_load, you're adding new parameter sql datasource, though parameter defined.

try instead - setting value of existing parameter:

protected void page_load(object sender, eventargs e) {    membershipuser currentuser = membership.getuser();    guid userid = (guid)currentuser.provideruserkey;    answered.selectparameters["userid"].defaultvalue = userid.tostring().trim(); } 

does change anything?


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -