|
Mark Nischalke wrote: Stop cross posting and you may get a reply.
He needs to see the one I gave him. Granted it is a google search, it pretty much gives him alot of information at his fingertips
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I am trying to install IIS 7.0 in windows Vista operating system.I cant find an option called windows Authentication on IIS 7.o.
What is the option that substitute this Option(windows authentication).
Please advice
Thanks
|
|
|
|
|
Stop cross posting and you may get a reply.
only two letters away from being an asset
|
|
|
|
|
Geeze, another cross post by the OP
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hello guys, I was wondering how do I delete a particulat record from a data grid. In other words I'm displaying bunch of messages to teh user and then there is going to be a button that will allow us to delete the message that is selected (by the way, Data grid has a check box colum which needs to be checked and the checked message would be deleted). Now I know that in 2.0, the Grid view has built in supprot for updates and deletes, but this button (DELETE) needs to just show up at the top just once in the header and not next to every single row in the data grid...could some one tell me how do I go through each row in grid view, and based on what's checked, delete that record from the Data base.
Thanks
|
|
|
|
|
Can someone please help me with this....THanks
|
|
|
|
|
Don't be so impatient. No one is required to answer your questions, it is all voluntary here. If you want immediate answers call the support number.
only two letters away from being an asset
|
|
|
|
|
You have a couple of options with this. First you can put the delete button outside of the gridview all together. I have done that before when you have a check box to say which row to delete. Otherwise if you want the delete button to only show up once, I have used the pager template for that. There are a few issues that have to be overcome. Like you need to turn paging on and if the number of items is less then your page size your pager template hides it self so you have to make it visible again. So by far the easiest thing to do is put the delete button outside of the gridview.
Hope that helps.
Ben
|
|
|
|
|
Thanks Ben, that’s probably what I’m going to end up doing. Since you did it as you mentioned, would you be able to show me some code sample…I mean there’s help available online if you are using the built in grid view Delete row feature (without the checkbox and one delete button implementation)…but I couldn’t find any code examples for the scenario we are dealing with. Could you please help me out???
Thanks
|
|
|
|
|
I can send you some code, but it is in C# I don't know if that matters and I was using a object datasource that was returning a generic collection of an interface. So that might not be exactly what you are dealing with. Let me know if you still want to see the code.
Ben
|
|
|
|
|
Thanks once again Ben, yes I’d def like to see what you’ve got since I’m kind of stuck out here, also I’m using C# as well. In my case too, there’s an object datasource which brings back all the messages ( by calling the method GetAllMessages() and then I’m brinding that object directly against the datagrid (gridview) . The problem I’m having is what to put in protected void Deletebtn_Click(object sender, EventArgs e) Delete’s button’s event handler.
Right now, I’m just calling the DeleteRow method on the GridView from with in the Delete button click event handler.
Also, the actual Row_Deleting event needs to perform the deletion….isn’t that right, so I’d have to do the actual Database delete in the following:
protected void messageGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Perform delete here ????
}
Yes, so your code will def help.
Thanks once again Ben.
|
|
|
|
|
For the delete button outside of the grid view here is the code I am using:
NOTE in all my gridviews I have the first column in the gridview be a template column that has a label that contains the database table unique id. I mark this label as not visible, so it doesn't show up on the web page, but it is in the code behind, so I know what datarow I am dealing with.
protected void lBtnDeleteList_Click(object sender, EventArgs e)
{
if (SomethingChecked() == 0)
{
this.custValidatorSendtoEmail.ErrorMessage = "Please check a list to delete.";
this.custValidatorSendtoEmail.IsValid = false;
return;
}
GridViewRow gvr = null;
Label listID = null;
for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
gvr = this.GridView1.Rows[i];
if (((CheckBox)gvr.FindControl("chkBoxSelect")).Checked)
{
listID = (Label)gvr.FindControl("lbListID");
this.ObjectDataSource1.DeleteParameters["ListID"].DefaultValue = listID.Text;
this.GridView1.DeleteRow(i);
}
}
}
private int SomethingChecked()
{
int ret = 0;
foreach (GridViewRow gvr in this.GridView1.Rows)
{
if (((CheckBox)gvr.FindControl("chkBoxSelect")).Checked)
{
ret += 1;
}
}
return ret;
}
Hope that helps.
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:
<asp:templatefield headertext="Select All">
<itemtemplate>
<asp:checkbox id="testChkBox" runat="server">
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
|
|
|
|
|
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?
|
|
|
|