|
To get the code with < and > in it you have to check the box below before posting that says "Ignore HTML tags in this message"
Ben
|
|
|
|
|
Thanks for the tip Ben, for now though I got it in without the opening angle brackets
|
|
|
|
|
Here is my objectdatasource:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetListsByUser" TypeName="ManageListLogic"
UpdateMethod="UpdateListOnly" DeleteMethod="DeleteList" >
<SelectParameters>
<asp:SessionParameter Name="p_user" Direction="Input" SessionField="CurrentUser" />
<asp:Parameter Name="p_sortExpression" Type="String" DefaultValue="ModifiedDtm" />
<asp:Parameter Name="p_sortDirection" Type="String" DefaultValue="Descending" />
<asp:Parameter Name ="p_discount" Direction="input" />
</SelectParameters>
<UpdateParameters>
<asp:SessionParameter Name="p_user" Direction="Input" SessionField="CurrentUser" />
<asp:Parameter Name ="p_discount" Direction="input" />
</UpdateParameters>
<DeleteParameters>
<asp:SessionParameter Name="p_user" Direction="Input" SessionField="CurrentUser" />
<asp:Parameter Name ="ListID" Direction="input" />
</DeleteParameters>
</asp:ObjectDataSource>
Ben
|
|
|
|
|
Hi Ben, I guess I'm not really familiar with the whole concept of Parameters tags <parameter> as you are showing in your code. Can you please tell me how do I/ or what should I do in the Grid’s event handler for deletion i.e. protected void messageGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
I mean is it where I should be actually calling a method such as DeleteMessages() or something which will have a delete query???? I know I’m being annoying, but I am pretty new..hope you can help. Thanks Ben.
|
|
|
|
|
Thanks Ben, SomethingChecked() func makes perfect sense, this is how I did It too; however my data grid’s first column is a checkbox column with the item template like this:
<br />
<asp:TemplateField HeaderText ="Select All"><br />
<ItemTemplate><br />
<br />
<br />
<asp:CheckBox ID="testChkBox" runat="server" /><br />
<br />
</ItemTemplate><br />
</asp:TemplateField><br />
<br />
Since I have the message ID that I’m getting from that object I told you about also saved in the database, what I could do is add another column before the checkbox colums with the label displaying the Message ID (and then make it’s visibility attribute false).
So now looking at your code, the part I’m not understanding is
if (((CheckBox)gvr.FindControl("chkBoxSelect")).Checked)
{
listID = (Label)gvr.FindControl("lbListID");
this.ObjectDataSource1.DeleteParameters["ListID"].DefaultValue = listID.Text;
//Note we have set up a delete method in the object data source to take in the
//listid and delete that list.
this.GridView1.DeleteRow(i);
}
Specially where you have ObjectDataSource1.DeleteParameters["ListID"].DefaultValue = listID.Text;
I’m assuming that this method (DeleteParameters) is something that is custom written by you in that ObjectDataSource1 object. I’m getting a little confused here. Could you give me some pointers for my specific situation????
Thanks
|
|
|
|
|
Thanks Ben, SomethingChecked() func makes perfect sense, this is how I did It too; however my data grid’s first column is a checkbox column with the item template like this:
<br />
asp:TemplateField HeaderText ="Select All"><br />
ItemTemplate><br />
<br />
<br />
asp:CheckBox ID="testChkBox" runat="server" /><br />
<br />
/ItemTemplate><br />
/asp:TemplateField><br />
<br />
Since I have the message ID that I’m getting from that object I told you about also saved in the database, what I could do is add another column before the checkbox colums with the label displaying the Message ID (and then make it’s visibility attribute false).
So now looking at your code, the part I’m not understanding is
if (((CheckBox)gvr.FindControl("chkBoxSelect")).Checked)
{
listID = (Label)gvr.FindControl("lbListID");
this.ObjectDataSource1.DeleteParameters["ListID"].DefaultValue = listID.Text;
//Note we have set up a delete method in the object data source to take in the
//listid and delete that list.
this.GridView1.DeleteRow(i);
}
Specially where you have ObjectDataSource1.DeleteParameters["ListID"].DefaultValue = listID.Text;
I’m assuming that this method (DeleteParameters) is something that is custom written by you in that ObjectDataSource1 object. I’m getting a little confused here. Could you give me some pointers for my specific situation????
Thanks
|
|
|
|
|
Since you are using an object data source you can put all of the select update and delete methods in a sepparate class. So my site has a middle tier logic layer that is accessed before the database layer. You don't have to do it that way, you can have the methods in the code behind of your page as well.
Ben
|
|
|
|
|
Hi Ben, I guess I'm not really familiar with the whole concept of Parameters tags as you are showing in your code. Can you please tell me how do I/ or what should I do in the Grid’s event handler for deletion i.e. protected void messageGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
I mean is it where I should be actually calling a method such as DeleteMessages() or something which will have a delete query???? I know I’m being annoying, but I am pretty new..hope you can help. Thanks Ben.
|
|
|
|
|
If you want to use the objectdatasource to do the deletes, you have to tell it in the objectdatasource which method it is to call. Since the object datasource delete tend to work off one record at a time, you will need to pass the id of the record you want to delete. So the code I have posted calls the delete method defined in the objectdatasource for each of the ids that I get based off which items are checked. So you need to make a method that accepts one parameter set it up in the object datasource and then call it like the code I posted.
Ben
|
|
|
|
|
I'm not too sure what you mean by that. I mean when you say that if you want to use objectdatasource to do deletes, I’m thinking there’s gotta be a way without it too. See my Message class has a method that has the query along with the ADO.Net code to perform the delete, it only requires the message ID that I will be able to extract. So question is how do I set it all up…. I mean right now in the code behind file I have protected void Deletebtn_Click(object sender, EventArgs e) and
protected void messageGridView_RowDeleting(object sender, GridViewDeleteEventArgs e).
Where messageGridView is the Data grid. Could you please send me something that would work with this sort of setup. In other words how do I call deleteMessage() and from where in this situation. Or if I use that obJectdatasource (which I totally could and add the name of the method for the DeleteMethod property, how would I hook it up to the event handler of the DELETE button?? Please help? Thanks Ben
|
|
|
|
|
Ok the easy way is:
If you have a delete button outside of the gridview I believe that is your Deletebtn_Click, inside of that method loop through the grid view items see if they are checked. If they are then call your deleteMesage() method, passing it the id of the item you want to delete. Do worry about setting the objectdatasource delete method.
Ben
|
|
|
|
|
Thanks Ben, i'm assuming in the end you meant, DON'T worry about setting the objectsource??? Correct?
|
|
|
|
|
Sorry about that yes DON't worry about the objectdatasource. I guess what I am thinking in my head doesn't always make it to my fingers.
Ben
|
|
|
|
|
Hi all, I have developed in asp.net with vb.net. There is a Data Grid on that page. I bring Data from Different tables to this Data Grid.
Now I want to sort the data of this Data Grid.
Is it possible ?
If yes then how ?
Any Example ?
Pls Help its very urgent.
Thanks in Advance.
|
|
|
|
|
Actually what you can do is sort the actual table, you can either provide a sort expression on the default view of the of the DataTable and bind your DataGrid to that view using the DataSource property of the DataGrid
Greets! Joel
|
|
|
|
|
you can use dataview to sort the records.
assign the table.defaultview with the dataview.
Then you can sort it with the column name.
dim dtview as new dataview=table.defaultview
dtview.sort(columnName)
All The Best
Sathesh Pandian
|
|
|
|
|
Dear Actually I have a Data Grid and its different columns are set by different functions. For example first column is set by func1,2nd column is set by func2, similiry other columns are set by different functions.
Now there is a column Customer Name,
I want to sort this Data Grid with the help of this column. Is there any method with the help of which I can sort it. I want to sort this Data with the Data Which is in this Column, not with Data base table.
How is that possible.
|
|
|
|
|
If u can create the stored procedure into DB and use join query for all records thn use the order by clause for that.
hope that'll help u.
Deepak
Smile a Lots,Its Costs Nothing
|
|
|
|
|
I have content:
<table class="clTable" style="width: 100%;" border="0" cellpadding="0" cellspacing="1">
<tbody>
<tr>
<td>
<table class="clTableList" style="width: 100%;" border="0" cellpadding="2" cellspacing="1">
<tbody><tr>
<td class="clItem1">New York</td><td class="clItem2"><img src="DuBaoThoiTiet_files/clear.gif" border="0"></td><td class="clItem3">28°C</td>
</tr><tr>
<td class="clItem1">Washington, D.C.</td><td class="clItem2"><img src="DuBaoThoiTiet_files/clear.gif" border="0"></td><td class="clItem3">23°C</td>
</tr><tr>
<td class="clItem1"> Florida </td><td class="clItem2"><img src="DuBaoThoiTiet_files/clear.gif" border="0"></td><td class="clItem3">23°C</td>
</tr><tr>
<td class="clItem1">Los Angeles</td><td class="clItem2"><img src="DuBaoThoiTiet_files/clear.gif" border="0"></td><td class="clItem3">24°C</td>
</tr><tr>
<td class="clItem1">Houston</td><td class="clItem2"><img src="DuBaoThoiTiet_files/clear.gif" border="0"></td><td class="clItem3">27°C</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody></table>
Can you define a regular to get the above City wheather?
Thank in advance
vtkiet05
|
|
|
|
|
hi all,
How to authorize user into web application using windows active directory?
Could you also recomend me a article.
|
|
|
|
|
Hi,
I am new to this <asp:templatefield>.
i m binding gridview with database not using SqldataSource tool.
can u give the some example or sample projetc.
Thanks
|
|
|
|
|
|
I am currently writing a dynamic asp.net site, but I want to find out what the implications will be if I save the content of the pages in the database and load it when the user selects the page.
Reason I want to do this is that I want to add a content editor to the site, so if the editor wants to update the text of the page, he/she only updates the value from the database, this will be done through an editing page.
So back to my question, how will this influence search engine crawlers when the try to crawl my site, will they still be able to view the content(do they surf the same as users) or are they going to skip it because there is no actual content on the page itself?
Thanks in advance
He who laughs last is a bit on the slow side
|
|
|
|
|
The content will be crawled, subject to the same caveats/conditions as a page saved as a bog standard html file.
If you think about it, it makes sense because content is merely passed across as a stream regardless as to whether or not it's a web browser or a spider.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks, for the reply.
He who laughs last is a bit on the slow side
|
|
|
|